[BangPypers] mac IP

Nitin Kumar nitin.nitp at gmail.com
Fri Apr 15 07:29:58 CEST 2011


Ya this is the issue,

I am writing code generic to all OS (windows 7, XP, mac) so ioctl wont be
good to use.

Nitin K

On Thu, Apr 14, 2011 at 7:15 PM, Noufal Ibrahim <noufal at gmail.com> wrote:

> 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?
>
> --
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
Nitin K


More information about the BangPypers mailing list