-
#!/usr/bin/env python import subprocess r = subprocess.run("net 4e:4f:50", shell=True, capture_output=True) macs = [] lines = r.stdout.split(b"\n") for line in lines: if b"4E:4F:50" in line: _, data = line.split(b"4E:4F:50") suffix = data.split(b" ")[0] macs.append(f"4E:4F:50{str(suffix, 'utf-8')}") for line in sorted(macs): print(line)
-
Improved version sorts by MAC address, but shows all
net
fields.#!/usr/bin/env python import subprocess r = subprocess.run("net 4e:4f:50", shell=True, capture_output=True) macs = {} lines = r.stdout.split(b"\n") for n, line in enumerate(lines): line = str(line, "utf-8") if n < 2: print(line) if "4E:4F:50" in line: _, data = line.split("4E:4F:50") suffix = data.split(" ")[0] mac = f"4E:4F:50{suffix}" entry = macs.get(mac, []) entry.append(line) macs[mac] = entry for mac in sorted(macs.keys()): lines = macs[mac] for line in lines: print(line)
Edited by tfors
Please register or sign in to comment