Trip Posted May 25, 2011 Share Posted May 25, 2011 (edited) import commands def getmac(iface): data = commands.getoutput("ifconfig " + 1face) words = data.split() found = 0 for x in words: #print x if found != 0: mac = x break if x == "HWaddr": found = 1 if len(mac) == 0: mac = 'Mac not found' mac = mac[:17] return mac im sure there is a better method for looping round the word list numerically rather than having to wait for the next step to grab the mac ... ie. if words[x].strip() == 'HWaddr': mac = words[x+1] break but havent found an easy way of grabbing the upper bound number from the string array. if you know a better way of doing this please let me know ;0) Edited May 25, 2011 by Trip Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.