Collecting active SSID with macOS Sonoma 14.4 and later

sdagley
Esteemed Contributor II

As of macOS Sonoma 14.4 using "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --getinfo" no longer returns info about the active Wi-Fi connection. If you want to collect the active SSID for macOS 14.4 or later you can use the wdutil tool and here's an EA to do that: 

 

#!/bin/sh

# EA - ActiveSSID
#
# Note: Using wdutil instead of networksetup so I don't need to know what
# interface is Wi-Fi

# Returns the currently active SSID
activeSSID=$(/usr/bin/wdutil info | /usr/bin/awk '/SSID                 :/ { print $NF }')

echo "<result>$activeSSID</result>"

 

2 REPLIES 2

DBrowning
Valued Contributor II

If you didn't want to have so many spaces in your call, you can use 

/usr/bin/wdutil info | /usr/bin/awk '/SSID/ { print $NF }' | head -n 1

daniel_behan
Contributor III

This one works for me.

#!/bin/sh

##Get the wireless port ID
WirelessPort=$(networksetup -listallhardwareports | awk '/Wi-Fi|AirPort/{getline; print $NF}')

##What SSID is the machine connected to
SSID=$(networksetup -getairportnetwork "$WirelessPort" | cut -d " " -f4)

echo "<result>$SSID</result>"