Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Determining Ethernet HW Address
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mark Hammond  
View profile  
 More options Mar 28 2000, 3:00 am
Newsgroups: comp.lang.python
From: "Mark Hammond" <mhamm...@skippinet.com.au>
Date: 2000/03/28
Subject: Re: Determining Ethernet HW Address
"Darrell" <darr...@dorb.com> wrote in message

news:dhSD4.7202$JE5.97355@typhoon.nyroc.rr.com...
> "Jerome Chan" <evilt...@rocketmail.com> wrote in message
> > Is there a portable way of determining the Ethernet HW
Address?

> For windows without using Win32 try parsing the output of

ipconfig /all

I couldnt resist :-)  In win32all-130 you will be able to use the
Netbios function:

    from netbios import *
    # code ported from "HOWTO: Get the MAC Address for an
Ethernet Adapter"
    # MS KB ID: Q118623
    ncb = NCB()
    ncb.Command = NCBENUM
    la_enum = LANA_ENUM()
    ncb.Buffer = la_enum
    rc = Netbios(ncb)
    if rc != 0: raise RuntimeError, "Unexpected result %d" %
(rc,)
    for i in range(la_enum.length):
        ncb.Reset()
        ncb.Command = NCBRESET
        ncb.Lana_num = ord(la_enum.lana[i])
        rc = Netbios(ncb)
        if rc != 0: raise RuntimeError, "Unexpected result %d" %
(rc,)
        ncb.Reset()
        ncb.Command = NCBASTAT
        ncb.Lana_num = ord(la_enum.lana[i])
        ncb.Callname = "*               "
        adapter = ADAPTER_STATUS()
        ncb.Buffer = adapter
        Netbios(ncb)
        print "Adapter address:",
        for ch in adapter.adapter_address:
            print "%02x" % (ord(ch),) ,
        print

Yields on my dual-NIC server:
Adapter address: 00 a0 cc 54 22 2d
Adapter address: 00 40 05 6b fc ca

(both of which are correct :-)

Mark.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google