If you need to determine the currently connected WiFi network from a command line interface (CLI), aka a shell prompt, on an Apple OS X system, e.g., a MacBook Pro laptop, you can do so by opening a Terminal window (the application is in
/Applications/Utilities) and issuing the command
networksetup -getairportnetwork wifi_devicewhere wifi_device is the port used for wireless connections on the system. You can determine the hardware port used for Wi-Fi connectivity on the system by issuing the command
networksetup -listallhardwareportsand then piping its output into the grep command looking for
Wi-Fiin the output and when it is found displaying that line and the two lines after it. E.g., in the example below,
en0is the relevant device interface for wireless connections and the SSID for the currently connected Wi-Fi network is "Hogwarts".
$ networksetup -listallhardwareports | grep -A 1 "Wi-Fi" Hardware Port: Wi-Fi Device: en0 $ networksetup -getairportnetwork en0 Current Wi-Fi Network: Hogwarts