On Sat, 11 Feb 2006 16:28:06 +0100, Martin v. Löwis <[EMAIL PROTECTED]> wrote: > billie wrote: >> Hi all. I don't know if Python is good for this kind of jobs but I'm >> wondering if it's possible emulate the "netstat" command in Python. > > As a general recommendation, use strace(1) to answer this kind of > question. Run "strace -o tmp netstat", then inspect tmp to find out > how netstat obtained the information it reported.
Good idea. There might still be a problem for people doing things like this: netstat might use unstable or non-public APIs to find the things it lists. This is fine because it's typically your OS vendor who have to handle that (ship another netstat when the /proc or /sys file system layout changes, etc). If it works like that, you can access the APIs fine from Python -- but you cannot write a portable 'pynetstat' without a lot of effort and maintenance. /Jorgen -- // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org> R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list