Skip to content

Instantly share code, notes, and snippets.

@mike-zhang
Created December 8, 2012 12:56
Show Gist options
  • Save mike-zhang/4240150 to your computer and use it in GitHub Desktop.
Save mike-zhang/4240150 to your computer and use it in GitHub Desktop.

Revisions

  1. mike-zhang revised this gist Jan 22, 2013. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions getMACAddress_win2.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    # just in windows
    import os

    var = os.popen("getmac /NH /FO csv").read()
    #print var

    macList = []
    for line in var.split("\n") :
    #print line.split(',')[0][1:-1]
    macAddrTmp = line.split(',')[0][1:-1]
    if macAddrTmp not in macList : macList.append(macAddrTmp)

    for macAddr in macList:print macAddr

    raw_input("Press Enter to continue")
  2. MikeZhang revised this gist Dec 8, 2012. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion getMACAddress_win.py
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,13 @@
    import os

    var = os.popen("wmic nicconfig get MACAddress").read()
    print var
    #print var

    macList = []
    for x in var.split(" \r\n"):
    if len(x.strip()) > 0 and x.find("MACAddress"):
    if x not in macList:macList.append(x)

    for macAddr in macList:print macAddr

    raw_input("Press Enter to continue")
  3. MikeZhang created this gist Dec 8, 2012.
    5 changes: 5 additions & 0 deletions getMACAddress_win.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # just in windows
    import os

    var = os.popen("wmic nicconfig get MACAddress").read()
    print var