Skip to content

Instantly share code, notes, and snippets.

@alejomongua
Created October 18, 2013 20:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alejomongua/7048177 to your computer and use it in GitHub Desktop.
Save alejomongua/7048177 to your computer and use it in GitHub Desktop.
Get MAC address python
import commands
def getmac(iface):
mac = commands.getoutput("ifconfig " + iface + "| grep HWaddr | awk '{ print $5 }'")
if len(mac)==17:
return mac
getmac('eth0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment