Prev: Importing modules
Next: ODFPY
From: joblack on 6 Jun 2010 23:47 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?
From: Tim Pinkawa on 7 Jun 2010 00:38 On Sun, Jun 6, 2010 at 10:47 PM, joblack <johannes.black(a)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
From: joblack on 7 Jun 2010 00:43 Great - seems to work =) ...
|
Pages: 1 Prev: Importing modules Next: ODFPY |