python脚本获取主机Mac地址

it2022-05-05  115

#!/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

 

转载于:https://www.cnblogs.com/Dev0ps/p/7778596.html

相关资源:SecureCRT读取交换机MAC地址表python脚本

最新回复(0)