Look up SSID my Wi-Fi interface is associated to, based on interface's IP address

0

How can I use bash to get the SSID name of the Wi-Fi network my Wi-Fi interface is associated to, when I know the Wi-Fi interface's IP address?

I get a list of IP addresses by using the ifconfig command. I want to display the SSID name along with the IP address as the output. I did check commands like networksetup, but found no way to do it. I can go the AppleScript way to get it, but would like to know if there is a way to do it in bash.

I did come across a command that helps me get the SSID name, but it doesn't print the IP address:

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I

I'm running OS X Yosemite (10.10.x)

smokinguns

Posted 2014-12-03T23:43:31.667

Reputation: 1 188

Answers

0

OS X doesn't support multiple Wi-Fi interfaces, so whatever SSID you get from airport -I is the SSID for your one single supported Wi-Fi interface.

You could probably write a loop walking through ifconfig enX to associate IP addresses with enX devices, and then run networksetup -getairportnetwork enX for each one, and whichever one returns a proper answer is your Wi-Fi interface.

Spiff

Posted 2014-12-03T23:43:31.667

Reputation: 84 656

I was able to get this to work using netstat and networksetup -getairportnetwork enX commands – smokinguns – 2014-12-05T01:44:20.130