Created
October 18, 2013 20:57
-
-
Save alejomongua/7048177 to your computer and use it in GitHub Desktop.
Get MAC address 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 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