def GetMac(): if os.name =='nt': try: ret ='' CmdLine ='ipconfig /all' r = os.popen(CmdLine).read() if r: L = re.findall('Physical Address.*?([0-9,A-F]{2}-[0-9,A-F]{2}-[0-9,A-F]{2}-[0-9,A-F]{2}-[0-9,A-F]{2}-[0-9,A-F]{2})', r) if len(L)> 0: ret = L[0] except: pass
elif os.name =="posix": try: ret ='' CmdLine ='ifconfig' r = os.popen(CmdLine).read() if r: L = re.findall('HWaddr.*?([0-9,A-F]{2}:[0-9,A-F]{2}:[0-9,A-F]{2}:[0-9,A-F]{2}:[0-9,A-F]{2}:[0-9,A-F]{2})', r) if len(L)> 0: ret = L[0] except: pass else: pass return ret
if__name__=='__main__': mac = GetMac() print mac m=raw_input()