RE - Parsing ipconfig /all output - question

J

joblack

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.

Here a test which isn't working:

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'(%X%X-){5}%X%X',rawtxt)
print p

Any ideas?
 
T

Tim Pinkawa

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top