Getting Process List On *nix

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Fri Jul 5 11:57:07 EDT 2002


On 05 Jul 2002 15:56:12 +0100, John Abel wrote:
> I am trying to write a script, capable of running on Win32, and *nix,
> which looks for certain processes.  However, I can't seem to find any
> details of how to access of list of running processes under *nix,
> without shelling out, something I'm loathe to do.

Use os.popen().  I know you don't want to shell out, but trust me, it's easier
this way.  The process listing on proprietary Unix systems is sometimes in 
the kernel memory image (only) and sometimes exposed by the /proc 
filesystem interface (if you have that on your Unix).  Further AFAIK there
is no reliably implemented standard for how this data is to be retrieved.

On the other hand, adapting to the output format of different versions of the
ps command is pretty simple.
 
> I'd be grateful for any pointers.
> 
> John





More information about the Python-list mailing list