View Full Version : Need help with script for conditional airport connection...

Feb 11, 2009, 07:31 PM

My university is using some fancy new wireless authentication.
It can take me up to 4 hours to get an ip.
However, If I spend 10 minutes turning off airport, then reconnecting, it will usually obtain an address.

I'm not sure how I'd do this in apple script or a shell script...

Basically what I want to have happen is this:
connect to a specified ESSID
wait 10 seconds
check my ip with IFconfig every 5 seconds for 45 seconds to see if I pull in an ip that doesn't start with 169
If I pull down an ip that is not self-assigned close the script, else disconnect then repeat ad infinitum...

I'm not sure i can do all of this in a bash script... but this is what I've got...

i know it doesn't do anything...


# Setup and variables

# script

# I need some conditional statements here, I'm sure how to do it...
# basically if my ip starta with 169 I know its self assigned... unless there is a more efficient way of finding this out

# to get my IP i figured I;d use this

ifconfig $IFACE | grep "inet " | cut -d\ -f2

# disconnect from airport

# I know I don't need this, it's just laggy
sleep 15

# Reconnect
$AIRPORT_BIN --associate=$MY_ESSID

# wait 45 seconds to see if it pulls in a proper ip
sleep 45

I know its not much....

but any help would be greatly appreciated...