python脚本获取主机Mac地址
#!/usr/bin/python import re import subprocess ARP = "arp" IP = "192.168.128.27" CMD = "%s %s" % (ARP,IP) macPattern = re.compile(":") def getMac(): p = subprocess.Popen(CMD,shell=True,stdout=subprocess.PIPE) out = p.stdout.read() results = out.split() for chunk in results: if re.search(macPattern,chunk): return chunk if __name__ == "__main__": macAddr = getMac() print macAddr
如对您有帮助,支持下呗!
微信
支付宝