Information can be obtained with the command airport, which is somehow deep.
$ /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I
     agrCtlRSSI: xxx
     agrExtRSSI: xxx
    agrCtlNoise: xxx
    agrExtNoise: xxx
          state: xxx
        op mode: xxx
     lastTxRate: xxx
        maxRate: xxx
lastAssocStatus: xxx
    802.11 auth: xxx
      link auth: xxx
          BSSID: xxx
           SSID: HERE!!!
            MCS: xxx
        channel: xxx
Pull out only where you want it
Shell is like this
$ /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep " SSID" | tr -d " " | cut -c6-
HERE!!!
Python is like this
import commands
airport = "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I"
print [line for line in commands.getoutput(airport).split('\n') if " SSID" in line][0].split(':')[1].strip()
# HERE!!!
For example, I made a command line tool that I can use at home and at work, but I have to set a proxy at work.
Recommended Posts