No longe rable to obtain network name

We have a JavaScript api that queries our Secure Browser to get the network information – signal strength, network name, plugged in/wifi. Everything worked fine through the Tahoe betas, still does. Now we are getting <restricted> on the network name and this is breaking our UI. Was this an intentional change or a bug? The other two properties still appear to be working. And it works in all lower MacOS versions.

We are currently obtaining it through AppleScript

try   set ssid to do shell script "system_profiler SPAirPortDataType | awk '/Current Network Information:/ {getline; sub(/^ +/, ""); sub(/:$/, ""); print}'"   if ssid is equal to "" then     return "Not connected to any Wi-Fi network."   else     return ssid   end if on error errMsg   return "Error: " & errMsg end try

Answered by DTS Engineer in 861094022

Check the output for system_profiler SPAirPortDataType on your system as it may have changed and so you may need to change your awk script or make it more complex to identify the information you want.

When I tried this on my system with my current network configuration I saw two entries show up with a heading matching "Current Network Information:" and the second entry contained useful information. The first entry had that information replaced with "<redacted>". Below I have included a two different awk scripts you might want to use as a starting place for experimentation.

Depending on the information you're seeing where your script is being deployed you may need to write a more complicated awk script.


-- ignore the first entry
set awkScript to "/Current Network Information:/ { count++; if (count==2) { getline; sub(/^ +/, \"\"); sub(/:$/, \"\"); print } }"

-- ignore entries where the network type is "<redacted>"
set awkScript to "/Current Network Information:/ {  getline; sub(/^ +/, \"\"); sub(/:$/, \"\"); if ($0==\"<redacted>\") { next } else { print } }"

try
	set ssid to do shell script "system_profiler SPAirPortDataType | awk '" & awkScript & "'"
	if ssid is equal to "" then
		return "Not connected to any Wi-Fi network."
	else
		return ssid
	end if
on error errMsg
	return "Error: " & errMsg
end try

Accepted Answer

Check the output for system_profiler SPAirPortDataType on your system as it may have changed and so you may need to change your awk script or make it more complex to identify the information you want.

When I tried this on my system with my current network configuration I saw two entries show up with a heading matching "Current Network Information:" and the second entry contained useful information. The first entry had that information replaced with "<redacted>". Below I have included a two different awk scripts you might want to use as a starting place for experimentation.

Depending on the information you're seeing where your script is being deployed you may need to write a more complicated awk script.


-- ignore the first entry
set awkScript to "/Current Network Information:/ { count++; if (count==2) { getline; sub(/^ +/, \"\"); sub(/:$/, \"\"); print } }"

-- ignore entries where the network type is "<redacted>"
set awkScript to "/Current Network Information:/ {  getline; sub(/^ +/, \"\"); sub(/:$/, \"\"); if ($0==\"<redacted>\") { next } else { print } }"

try
	set ssid to do shell script "system_profiler SPAirPortDataType | awk '" & awkScript & "'"
	if ssid is equal to "" then
		return "Not connected to any Wi-Fi network."
	else
		return ssid
	end if
on error errMsg
	return "Error: " & errMsg
end try

Thanks! accepted

No longe rable to obtain network name
 
 
Q