RE - Parsing ipconfig /all output - question

Tim Pinkawa timpinkawa at gmail.com
Mon Jun 7 00:38:16 EDT 2010


On Sun, Jun 6, 2010 at 10:47 PM, joblack <johannes.black at gmail.com> wrote:
> I'm trying to get the first MAC address from the ipconfig /all output.
> Unfortunately you can't just search for Physical Address because the
> name is only valid in the English Windows version.

> Any ideas?

(accidentally sent original to Johannes only)

This filters out all the false positives on my machine (Windows 7 x64 English):

import subprocess
import re
p = subprocess.Popen('ipconfig /all', shell = True, stdout=subprocess.PIPE)
p.wait()
rawtxt = p.stdout.read()
print rawtxt

p = re.findall(r'\s([0-9A-F-]{17})\s',rawtxt)
print p

Tim



More information about the Python-list mailing list