Script no longer gets SSID. macOS 15.0 Sequoia

This problem occurred once before when I updated to OS 14.4 Sonoma. I was able, with help from Viking, to rewrite my automator application to work correctly. At the time the change was to:


use framework "CoreWLAN"

use scripting additions

property ca : current application


# body of script


set wif to ca's CWInterface's interface

set mySSID to (do shell script "networksetup -getairportnetwork " & (wif's |name|) & " | awk '{print $4}'")

set feedback to display dialog "You are currently connected to " & mySSID & " LAN.


It appears that macOS 15.0 Sequoia no longer get the current information to display mySSID using this method. Hopefully I can get pointed in the right direction. I don't program much anymore, so if you need me to provide the who automator workflow/app I can.


Thanks in advance for your help.


Diveboss

Posted on Sep 17, 2024 11:53 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 17, 2024 1:33 PM

One slower method to get the SSID in Sequoia is the following:


system_profiler SPAirPortDataType | awk '/Current Network/ {getline;$1=$1;print $0 | "tr -d ':'";exit}'



7 replies

Sep 17, 2024 6:53 PM in response to Diveboss164

What you need is a means to detect the major version of the operating system and set up an if/else condition to handle CoreWLAN stuff if the O/S version is 12 or less, and to use the system_profiler approach if it is macOS Sequoia 15 or greater.


Right after your first three set statements, you include this code:

considering numeric strings
	set osvString to system version of (system info)
    -- keep the major macOS version (e.g. 12)
	set osvers to (text 1 thru -5 of osvString) as text
end considering



Now, add another parameter to your handler Get_User_Feedback(osversion, Remain_time, Step_delay):

repeat until (Decision > 0) or (wait_time = 0)
	set Decision to Get_User_Feedback(osvers, wait_time, Refresh_time)
	set wait_time to wait_time - Refresh_time
end repeat


and use that osvers to form a decision tree in the handler whether you have Ventura and earlier that allows CoreWLAN framework, or the osvers is 15 which would require the system_profiler approach:

on Get_User_Feedback(osversion, Remain_time, Step_delay)
	set wait_time to 5 as integer
	if (osversion < 15) = true then
	   set wif to ca's CWInterface's interface
	   set mySSID to (do shell script "networksetup -getairportnetwork " & (wif's |name|) & " | awk '{print $4}'")
	else
	   set mySSID to (do shell script "system_profiler SPAirPortDataType | awk '/Current Network/ {getline;$1=$1;gsub(\":\",\"\");print;exit}'")
    end if
︙
end Get_User_Feedback



Sep 17, 2024 8:41 PM in response to VikingOSX

Thanks! With what you provided and a little adjustment to my timing values I was able to get it to countdown in 10 second increments. Approx 5 secs for the "system_profiler SPAirPortDataType | awk '/Current Network/ {getline;$1=$1;gsub(\":\",\"\");print;exit}'") to execute plus 5 seconds of display before screen refresh for count-down. It's back!!


Thanks again. Have a wonderful rest of the year.

Sep 17, 2024 1:03 PM in response to Diveboss164

Sequoia now breaks commands and/or syntax that worked in Sonoma and Ventura, though the developer's page for CoreWLAN -> CWWiFiClient does not indicate an alteration to the methods used below:


  1. networksetup -getairportnetwork en1
    1. The error message is: You are not associated with an AirPort network.
  2. AppleScript/Objective-C: ((CWWiFiClient's sharedWiFiClient)'s interface()'s ssid()
    1. The error is: missing value
  3. AppleScript/Objective-C: ((CWWiFiClient's sharedWiFiClient)'s interfaceWithName:"en1")'s ssid()
    1. The error is: missing value


And the following swift code that worked fine on Sonoma 14.6.1 now just returns a blank result:


//
// xcrun --sdk macosx swiftc -Osize -o ssid ssid.swift
//
//  GetSSID
//
//  Mostly https://developer.apple.com/forums/thread/50302
//

import Foundation
import CoreWLAN
 func currentSSIDs() -> [String] {
    let client = CWWiFiClient.shared()
    return client.interfaces()?.compactMap { interface in
        return interface.ssid()
        // return interface.bssid()
     } ?? []
 }

 print(currentSSIDs().joined(separator: ", "))


and on the command-line, the following continues to show <redacted> for SSID and BSSID:


sudo wdutil info | egrep SSID | cut -d ':' -f2




Sep 17, 2024 4:54 PM in response to VikingOSX

Hi Viking OSX,


Thanks for some ideas. I tried both using terminal to see the results and while they are a little slow they worked.

I'm am going to include with this post my script and ask if you would mind showing me where to incorporate either suggestion. You helped me with this one when I had updated the macOS 14.4. Now with 15.0 I would like to get it working again. Everything is working with the exception of the getting and/or displaying the SSID.


I run this at startup and the current script usually took 5-10 seconds before displaying the SSID, so if I can get it to work with one of the system_profiler suggestions the slowness should not be an issue.


Thanks for your help. It's appreciated.

Diveboss164


----- My current Automator application----


use framework "CoreWLAN"

use scripting additions


property ca : current application


# property dialog_icon : "Macintosh SSD:Users:user:Automator Custom Icons:Synology 5 bay DiskStation DS1512+.icns"


property app_icon : "Macintosh SSD:Users:me:Pictures:Logos:Image2icon:Synology 5 bay DiskStation DS1512+.icns" as text


set Refresh_time to 5 -- the delay between refresh of the dialog

set wait_time to 60 --total delay for user to decide

set Decision to 0


repeat until (Decision > 0) or (wait_time = 0)

set Decision to Get_User_Feedback(wait_time, Refresh_time)

set wait_time to wait_time - Refresh_time

end repeat


-- display alert "Decision is " & Decision

-- 0 means no answer

-- 1 means Connect

-- 2 means don't connect


if Decision is 2 then

quit

end if


-- your program here


if Decision = 1 or Decision = 0 then

tell application "Finder"

try

mount volume "smb://VogtStudios/home/Drive"

delay 1

end try

end tell


-- end routine

return


on Get_User_Feedback(Remain_time, Step_delay)

set wait_time to 5 as integer

set wif to ca's CWInterface's interface

set mySSID to (do shell script "networksetup -getairportnetwork " & (wif's |name|) & " | awk '{print $4}'")

set feedback to display dialog "You are currently connected to " & mySSID & " LAN.


You will be connected to the " & mySSID & " Server in " & Remain_time & ¬

" seconds. If your are not on MyServer Local Area Network, please select 'Don't Connect'." buttons {"Don't connect", "Connect Now"} default button ¬

"Connect Now" with icon app_icon as alias giving up after wait_time


if gave up of feedback then

return 0

else if button returned of feedback is "Connect Now" then

return 1

else

return 2

end if

end Get_User_Feedback

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Script no longer gets SSID. macOS 15.0 Sequoia

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.