Johny schrieb:
To get a number of the http processes running on my Linux( Debia box)
I use
ps -ef | grep "[h]ttpd" | wc -l
But If I want to use to get a number of the http processes from my
Python program I must use a popen command e.g.
popen2.popen3('ps -ef | grep "[h]ttpd" | wc -l')
that is I must call an external command from Python.
The shell does the exact same thing. And by the way: i think you miss a
grep -v grep
after the first grep - otherwise you count the grep itself.
But it creates a zombie.
Try using the subprocess module. It should not require you to call wait
yourself.
So my question is:
Is it possible to get a number of the http processes running on Linux
directly from Python ?
Not really, or at least not with less effort & without duplicating
system tools functionality.
Diez
--
http://mail.python.org/mailman/listinfo/python-list