29
Nov
2008

Connect to low signal wifi network with an Airport in OSX

This post is about the technical details of getting my internet to work, if you’re looking for stories of my life, go here

I’ve been having a lot of problems connecting to my neighbor’s wireless access point (with his permission) but finally found a solution. This solution only works if you know which network you want to connect to, but it doesn’t show up in the wireless network list (all of the times) when you click the Airport symbol in your menu-bar. By the way, did you know you can click it holding the option/alt-key too?

I’ve got a first generation MacBook Pro with a 802.11b Aiport card inside and because of the aluminum casing my reception of networks is not great. I’ve tried a lot to connect to this low signal network, especially when I noticed that with Windows XP on BootCamp I could connect fairly easy with the same hardware to the same router using the ‘Repair’ option (which basically turns the airport off and on and tries to find networks, I guess).

I read a lot about wifi connections while trying to get it to work. I threw away all of my network configuration files, reinstalled OS X, and heck, I even tried this solution. Finally I found the command line utility “airport” which ships with OS X. Of course, this isn’t a secret tool or anything, but you got to know it’s there.

One of the nice things about this tool is that it has a repeat functionality. So you can basically say

airport --associate=networkSSID --password=networkKey -r 10

And it will repeatedly try to connect with the network for 10 times. Eventually I got my MBP to connect with the wireless network with this command. Sometimes I had to run it for a couple of times before it worked, but it’s a sort of steady solution. While trying to make things more easy, I wrote a little bash script that tries to connect a wifi network until it succeeds. I named it connect.sh and you should invoke it with the SSID (the name) of the network you are trying to connect with as the first, and the password of the network as the second argument:

./connect.sh networkSSID networkPassword

Here is the contents of the script connect.sh:

#!/bin/bash
AIRPORT=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport
CUR_SSID=`$AIRPORT -I | grep " SSID:" | sed "s/.*SSID: //"`
SSID=$1
PASS=$2
while [ "$SSID" != "$CUR_SSID" ]
do
  echo "Desired SSID: $SSID, current SSID: $CUR_SSID, trying to change..."
  sudo $AIRPORT --associate=$SSID --password=$PASS
  CUR_SSID=`$AIRPORT -I | grep " SSID:" | sed "s/.*SSID: //"`
done
echo "Connected to $CUR_SSID"

And you can also download it.

Written by Niels van Hoorn in: Computers |

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress | Based on Aeros Theme