Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

stepweb

macrumors newbie
Original poster
Arg.

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...

#!/bin/bash

# Setup and variables
AIRPORT_BIN="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport"
MY_ESSID="EXAMPLE"
IF_BIN="/sbin/ifconfig"
IFACE="en1"

# 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
$AIRPORT_BIN -z

# 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...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.