Posted on 10-31-2024 06:04 PM
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.
Posted on 11-01-2024 06:26 AM
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>"
10-31-2024 07:26 PM - edited 10-31-2024 07:28 PM
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.
Posted on 10-31-2024 07:37 PM
I see. How can I find the SSID of the current connection in Sequoia?
10-31-2024 07:59 PM - edited 10-31-2024 08:08 PM
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.
Posted on 11-01-2024 06:26 AM
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>"
Posted on 11-03-2024 05:42 PM
Very good. Thank you very much!!!