AirPort Scanning from Bash

In the process of writing Monitor Your Web Services form Bash, I realized that there are a few commands that I use in a similar way — why not share them?!

In Mac OS X you often interact with wireless networks via the top-menu, but you also have access via command-line.

In this above view you can see the signal strength and that it only gives you 5 different values. This is good enough for a casual observation, but for other purposes we may need something better — enter the command line!

1. Scanning the network

$ export PATH=$PATH:/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources

$ airport -s

    SSID BSSID             RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
2WIRE442 3c:ea:4f:cb:a9:a9 -86  6       N  US WEP
      gb 00:25:4b:07:3f:8d -65  2       Y  US WPA2(PSK/AES/AES)

2. Viewing Current Connection Strength

$ airport -I

     agrCtlRSSI: -71
     agrExtRSSI: 0
    agrCtlNoise: -94
    agrExtNoise: 0
          state: running
        op mode: station
     lastTxRate: 104
        maxRate: 130
lastAssocStatus: 0
    802.11 auth: open
      link auth: wpa2-psk
          BSSID: 0:25:4b:7:3f:8d
           SSID: gb
            MCS: 13
        channel: 2

3. Watching the current connection strength in real-time

Updates twice a second with the details above output. I find this very useful when I'm curious about how

$ watch -n 0.5 airport -I