Controlling the Airport from the command line

Both my MacBook Pro and my 20″ iMac are running Leopard 10.5.8. On both machines, it’s easy to turn off the Airport from the command line:

sudo ifconfig en1 down

On the MacBook Pro, it’s also easy to turn the Airport back on in the obvious way:

sudo ifconfig en1 up

But on the iMac, nothing happens if I issue that command. I don’t know why, but tonight I discovered how to get the job done:

sudo networksetup -setairportpower On

Why did I care, you might ask? Until 10.5.8, the iMac wouldn’t reliably join the network after the machine woke from sleep (or rebooted), and I had to turn the Airport off and on — I could turn it off easily enough from the command line, but I had to use the GUI to turn it back on, which seemed silly. Now I can do the whole thing from the command line (but with luck, I won’t have to).

This entry was posted in Computer Stuff. Bookmark the permalink.

Comments are closed.