[Tutor] pstree cgi-script

Conrad Gavin gubbs at fudo.org
Fri Jun 18 15:50:08 EDT 2004

On Wed, 2004-06-16 at 22:53, Danny Yoo wrote:
> 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:
> ######
> #!/usr/bin/python
> import sys
> import os
> import cgitb; cgitb.enable()
> sys.stdout.write("Content-type: text/plain\n\n")
> cmd = "/usr/bin/pstree"
> status = os.popen(cmd).read()
> print status
> ######
> 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.
> Good luck!

Danny .. this is still not working for me! I have tested it on a remote
server running Apache 1.3 in addition to my local machine running Apache

I have ensured that the user Apache runs as owns the script and that all
paths and permissions are correct and it _still_ returns a 500
'Premature end of script Headers' error ...

I am pretty much conceeding defeat at this point since it works
perfectly well as a python script but not it seems as a cgi one. 

There has to be a bug somewhere because this really seems dumb to me ..

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/tutor/attachments/20040618/02b2e90a/attachment.bin

More information about the Tutor mailing list