networksetup fails to detect Wi-Fi on MacBook Pro
I have an Apple Silicon M4 macBook Pro with macOS Tahoe 26.1.
When I open Terminal and type;
networksetup -listallnetworkports
then press enter, I get;
...
Hardware Port: Wi-Fi
Device: en0
Ethernet Address: 84:2f:57:86:3e:4a
...
so when I type this;
networksetup -getairportnetwork en0
and press enter, I get this;
You are not associated with an AirPort network.
Even though I have Wi-Fi enabled and turned on. I can even ping to the router and get replies.
I have even tried typing;
networksetup -getairportnetwork en1
and pressing enter. I then get;
en1 is not a Wi-Fi interface.
Can anyone help me to get this working so that I can use networksetup to detect Wi-Fi availablilty in a shell script?
Thanks.
MacBook Pro 16″, macOS 26.1