OS X Wireless Control from the CLI
Support this website by purchasing prints of my photographs! Check them out here.Here's a hard to find utility in OS X for working with wireless:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
The utility provides a lot of functionality normally provided by the wireless-tools packages on Linux, such as iwconfig, iwlist, etc. Here's the –help listing of the utility:
$ airport --help
Supported arguments:
-c[] --channel=[] Set arbitrary channel on the card
-z --disassociate Disassociate from any network
-I --getinfo Print current wireless status, e.g. signal info, BSSID, port type etc.
-s[] --scan=[] Perform a wireless broadcast scan.
Will perform a directed scan if the optional is provided
-x --xml Print info as XML
-P --psk Create PSK from specified pass phrase and SSID.
The following additional arguments must be specified with this command:
--password= Specify a WPA password
--ssid= Specify SSID when creating a PSK
-h --help Show this help
Unfortunately, the output of the commands are disimilar, so if you're parsing the output of the command (like I am), you'll need to rebuild your parser.
Also, there is an XML output option, but it uses the goofy Apple dictionary format where keys and values are siblings and maintain no sort of logical relationship. So, it may be easier to parse than the raw output, but you'll probably have to do some gross hacking to get it to work. Does anyone know of a clean way to parse “plist” xml?