Turning your Airport Card on and off
This is a simple tip I stumbled across a month or so ago. There were some bugs in Leopard wireless that wouldn’t let me connect to the encrypted wireless network at work after a machine was restarted. I found that turning the airport card on and off let me connect again. I hated having to remember this every time I restarted so I dug around and found that the command line tool networksetup can do it for me. Great!
This tool exists on Tiger machines in the Apple Remote Desktop client bundle. The path to it is:
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup
Fortunately they very kindly included it in the build for Leopard. The path in Leopard is:
/usr/sbin/networksetup
So, in Leopard, to turn the Airport card off enter the following in Terminal:
/usr/sbin/networksetup -setairportpower off
To turn the card back on change “off” to “on”. If you’re running Tiger make sure to change the path so it points to the app correctly.
Put both of these commands in an AppleScript, save it as an application and add it to your Login items. Then, when the machine is rebooted the card gets turned off and then on and in my case makes my wireless connection.
Snow Leopard changes
In Snow Leopard the command remains, however now you need to run it as sudo
. You also need to include the actual network device name AirPort is running on. You can get that by running the following command:
/usr/sbin/networksetup -listallhardwareports
You’ll see Airport listed and below it the device. If the machine does not have two Ethernet ports AirPort is commonly listed as “en1”
After you have that you include it in your command:
sudo /usr/sbin/networksetup -setairportpower en1 on
I’ve included these changes and a routine that will find the airport device in the Snow Leopard version of the script.
Click here to download a copy of the script for Tiger/Leopard:
Airport off and on
Click here to download a copy of the script for Snow Leopard:
Snow Leopard Airport off and on
networksetup is a great tool for administrators and even just people who want a little more control over their machines.
webmaster :: Jan.07.2008 :: Applescript, Management, Scripts, System, Terminal :: 23 Comments »