Skip to content

Instantly share code, notes, and snippets.

@andy6804tw
Created July 15, 2022 15:06
Get Wifi information on mac using Python
import subprocess
def get_wifi_info_mac():
process = subprocess.Popen(['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport','-I'], stdout=subprocess.PIPE)
out, err = process.communicate()
process.wait()
wifi_info = {}
for line in out.decode("utf-8").split("\n"):
if ": " in line:
key, val = line.split(": ")
key = key.replace(" ", "")
val = val.strip()
wifi_info[key] = val
return wifi_info
wifi_SSID = get_wifi_info_mac()["SSID"]
print(f"[1] Current WiFi Network: {wifi_SSID}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment