[Tutor] pstree cgi-script
dyoo at hkn.eecs.berkeley.edu
Wed Jun 16 18:53:54 EDT 2004
On Wed, 16 Jun 2004, Conrad Gavin wrote:
> Btw did you test this script on your own apache before sending it to me?
> Did it work?
Good question. No. *grin*
I have tested the following version of the code:
import cgitb; cgitb.enable()
cmd = "/usr/bin/pstree"
status = os.popen(cmd).read()
I can confirm that this works on my machine.
The major fix here is to use os.popen() instead of os.system().
os.system() returns the "errorlevel" of the program, not its standard
output. os.popen() is probably what you want to use to capture the output
of other programs.
More information about the Tutor