Skip to content

Instantly share code, notes, and snippets.

@danielpclark
Created September 1, 2012 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpclark/3569312 to your computer and use it in GitHub Desktop.
Save danielpclark/3569312 to your computer and use it in GitHub Desktop.
Get mac address for current system's wireless router.
#!/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