Re: portable Python ifconfig

2007-03-04 Thread Bart Van Loon
It was Sun, 4 Mar 2007 14:09:20 +0500, when Bart Van Loon wrote: > It was Sun, 4 Mar 2007 02:38:58 +0500, when Bart Van Loon wrote: >> Hi all, >> >> I'm looking for a portable (FreeBSD and Linux) way of getting typical >> ifconfig information into Python. > > After lots of trial and error (I'm prof

Re: portable Python ifconfig

2007-03-04 Thread Bart Van Loon
It was Sun, 4 Mar 2007 02:38:58 +0500, when Bart Van Loon wrote: > Hi all, > > I'm looking for a portable (FreeBSD and Linux) way of getting typical > ifconfig information into Python. After lots of trial and error (I'm proficient in C at all), I puzzled togehter the following. It works (at least

Re: portable Python ifconfig

2007-03-03 Thread Bart Van Loon
It was 3 Mar 2007 18:43:57 -0800, when MonkeeSage wrote: > Bart, > > Can you try this and let us know if it works for FreeBSD? thanks for you suggestions! > import socket, fcntl, struct > > def _ifinfo(sock, addr, ifname): > iface = struct.pack('256s', ifname[:15]) > info = fcntl.ioctl(s

Re: portable Python ifconfig

2007-03-03 Thread MonkeeSage
Bart, Can you try this and let us know if it works for FreeBSD? import socket, fcntl, struct def _ifinfo(sock, addr, ifname): iface = struct.pack('256s', ifname[:15]) info = fcntl.ioctl(sock.fileno(), addr, iface) if addr == 0x8927: hwaddr = [] for char in info[18:24

Re: portable Python ifconfig

2007-03-03 Thread MonkeeSage
On Mar 3, 7:17 pm, "MonkeeSage" <[EMAIL PROTECTED]> wrote: > I'm pretty sure the offsets would be different for BSD Then again, mabye not. http://freebsd.active-venture.com/FreeBSD-srctree/newsrc/compat/linux/linux_ioctl.h.html Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-

Re: portable Python ifconfig

2007-03-03 Thread MonkeeSage
On Mar 3, 3:38 pm, Bart Van Loon <[EMAIL PROTECTED]> wrote: > I'm looking for a portable (FreeBSD and Linux) way of getting typical > ifconfig information into Python. Here's a pure python version of the C extension, based on the recipes you posted. In this version, the 'addr' key will not exist f

portable Python ifconfig

2007-03-03 Thread Bart Van Loon
Hi all, I'm looking for a portable (FreeBSD and Linux) way of getting typical ifconfig information into Python. Some research on the web brought me to Linux only solutions http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/439094 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/43909