Skip to content

Instantly share code, notes, and snippets.

@keithweaver

keithweaver/get-wifi.py

Last active Jun 28, 2020
Embed
What would you like to do?
Get Wifi information on Mac OSx using Python
# I tried to use the pip install wifi but it really didn't work.
# So created this
import subprocess
process = subprocess.Popen(['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport','-I'], stdout=subprocess.PIPE)
out, err = process.communicate()
process.wait()
print(out)
'''
Print out is:
agrCtlRSSI: -50
agrExtRSSI: 0
agrCtlNoise: -91
agrExtNoise: 0
state: running
op mode: station
lastTxRate: 243
maxRate: 300
lastAssocStatus: 0
802.11 auth: open
link auth: wpa2
BSSID: 24:de:c6:a6:9c:da
SSID: QueensuSecure_WPA2
MCS: 14
channel: 44,1
'''
# SSID is the wifi name
@fabioviegas

This comment has been minimized.

Copy link

@fabioviegas fabioviegas commented Aug 25, 2018

Just a small suggestion: use the line below to print bytes with line break:

print("".join(map(chr, out)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.