[BangPypers] mac IP

Noufal Ibrahim noufal at gmail.com
Thu Apr 14 15:45:56 CEST 2011


On Thu, Apr 14 2011, Ruchir Shukla wrote:

> here is a sample code
>
>
>>>> import fcntl, socket, struct
>>>>
>>>> def getHwAddr(ifname):
> ...     s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
> ...     info = fcntl.ioctl(s.fileno(), 0x8927,  struct.pack('256s',
> ifname[:15]))
> ...     return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]
> ...
>>>> print getHwAddr('eth0')

[...]

The IOCTL request code is probably platform specific. Does it work on
MacOS?

-- 


More information about the BangPypers mailing list