3 weeks ago
I have a script that worked before OS15. After updating to OS15, the script became abnormal. Even if it connected to the allowed SSID and obtained the IP address, it would turn off and on WIFI infinitely. The following is the script. Thank you for your help~~
#!/bin/bash
# set the allowed SSID GUEST-VIP
allowed_ssid1="GUEST-VIP"
##Get the wireless port ID
wifi_port=$(networksetup -listallhardwareports | awk '/Wi-Fi|AirPort/{getline; print $NF}')
# current preferred SSID list
ssid_list=`networksetup -listpreferredwirelessnetworks $wifi_port | tail -n +2 | cut -c 2-`
# current connected SSID
connected_ssid=`networksetup -getairportnetwork $wifi_port | cut -c 24-`
# clean up ssid
IFS=$'\n'
for ssid in $ssid_list
do
if [ "$ssid" != "$allowed_ssid1" ]
then
networksetup -removepreferredwirelessnetwork $wifi_port $ssid
security delete-generic-password -a $ssid -D "AirPort network password"
#echo $ssid Not allowed, and removed
#else
#echo $ssid is allowed
fi
done
if [ "$connected_ssid" != "$allowed_ssid1" ]
then
networksetup -setairportpower $wifi_port off
networksetup -setairportpower $wifi_port on
fi
Solved! Go to Solution.
3 weeks ago
I updated my Extension Attribute for Sequoia and I'm able to obtain the connected SSID.
#!/bin/sh
##Get the wireless port ID
WirelessPort=$(/usr/sbin/networksetup -listallhardwareports | /usr/bin/awk '/Wi-Fi|AirPort/{getline; print $NF}')
##What SSID is the machine connected to
SSID=$(/usr/sbin/ipconfig getsummary "$WirelessPort" | /usr/bin/awk -F ' SSID : ' '/ SSID : / {print $2}')
echo "<result>$SSID</result>"
3 weeks ago - last edited 3 weeks ago
Not a bug, location privacy "feature".
Apple have disabled the "networksetup -getairportnetwork <port>" command in macOS 15, due to it being a way to get around location privacy. I'm not aware of any workaround.
3 weeks ago
I see. How can I find the SSID of the current connection in Sequoia?
3 weeks ago - last edited 3 weeks ago
Already answered, as any way to get the SSID would be "... a way to get around location privacy."
If you control your internal DNS, and say have a DNS name that is only available internally (preferably only on the wireless network in question), perhaps try testing a dns lookup for that host, if it resolve, the computer is on the correct network.
3 weeks ago
I updated my Extension Attribute for Sequoia and I'm able to obtain the connected SSID.
#!/bin/sh
##Get the wireless port ID
WirelessPort=$(/usr/sbin/networksetup -listallhardwareports | /usr/bin/awk '/Wi-Fi|AirPort/{getline; print $NF}')
##What SSID is the machine connected to
SSID=$(/usr/sbin/ipconfig getsummary "$WirelessPort" | /usr/bin/awk -F ' SSID : ' '/ SSID : / {print $2}')
echo "<result>$SSID</result>"
3 weeks ago
Very good. Thank you very much!!!