Re: Access to sysctl on FreeBSD?

2008-05-21 Thread Thomas Heller
Skye schrieb: Great, thanks for the help (I'm fairly new to Python, didn't know about ctypes) from ctypes import * libc = CDLL(libc.so.7) size = c_uint(0) libc.sysctlbyname(net.inet.ip.stats, None, byref(size), None, 0) buf = c_char_p( * size.value)

Re: Access to sysctl on FreeBSD?

2008-05-20 Thread Martin v. Löwis
How do I access the sysctl(3) call from Python on BSD? Specifically I want to retrieve: $ sysctl -d net.inet.ip.stats net.inet.ip.stats: IP statistics (struct ipstat, netinet/ip_var.h) So I'll need some way of getting to struct ipstat from Python as well At the moment, only through

Re: Access to sysctl on FreeBSD?

2008-05-20 Thread Skye
Great, thanks for the help (I'm fairly new to Python, didn't know about ctypes) from ctypes import * libc = CDLL(libc.so.7) size = c_uint(0) libc.sysctlbyname(net.inet.ip.stats, None, byref(size), None, 0) buf = c_char_p( * size.value) libc.sysctlbyname(net.inet.ip.stats,

Re: Access to sysctl on FreeBSD?

2008-05-20 Thread Skye
Nevermind, I seem to have found it on my own =] http://python.org/doc/2.5/lib/module-struct.html This module performs conversions between Python values and C structs represented as Python strings. It uses format strings (explained below) as compact descriptions of the lay-out of the C structs