Created
September 1, 2012 10:41
-
-
Save danielpclark/3569312 to your computer and use it in GitHub Desktop.
Get mac address for current system's wireless router.
This file contains 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
#!/usr/bin/python | |
import commands | |
def getmac(iface): | |
words = commands.getoutput("ifconfig " + iface).split() | |
if "HWaddr" in words: | |
return words[ words.index("HWaddr") + 1 ] | |
else: | |
return 'MAC Address Not Found!' | |
if __name__ == "__main__": | |
print getmac( "wlan0" ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment