OS X Wireless Control from the CLI

Looking for a better way to manage your org's technical proposals?

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?

Thomas Hunter II Avatar

Thomas Hunter II is a Software Engineer with 18+ years building scalable, production-grade systems. Deep expertise in Node.js, observability, and developer tooling, with a strong track record of driving architectural decisions, mentoring engineers, and improving customer facing technical documentation. Author of 5 books (including O'Reilly), certified by the OpenJS Foundation, and frequent international conference speaker.