Created
July 15, 2022 15:06
Get Wifi information on mac using Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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