Get wireless SSID through shell script on Mac OS X

后端 未结 3 1120
無奈伤痛
無奈伤痛 2020-12-07 12:02

Is there any way to get the SSID of the current wireless network through a shell script on Mac OS X?

3条回答
  •  孤街浪徒
    2020-12-07 12:38

    The command

    /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I
    

    will give you details about your current wireless network connection.

    To get specifically the SSID, use this command:

    /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk -F: '/ SSID/{print $2}'
    

    To retrieve SSID names that might have colons as well as spaces:

    /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I  | awk -F' SSID: '  '/ SSID: / {print $2}'
    

提交回复
热议问题