FAQ
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?

Search Discussions

  • Tim Pinkawa at Jun 7, 2010 at 4:38 am

    On Sun, Jun 6, 2010 at 10:47 PM, joblack 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
  • Joblack at Jun 7, 2010 at 4:43 am
    Great - seems to work =) ...

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 7, '10 at 3:47a
activeJun 7, '10 at 4:43a
posts3
users2
websitepython.org

2 users in discussion

Joblack: 2 posts Tim Pinkawa: 1 post

People

Translate

site design / logo © 2022 Grokbase