[Tutor] pstree cgi-script

Conrad Gavin gubbs at fudo.org
Tue Jun 15 21:23:03 EDT 2004

Hi there. 

I'm trying to write a simple little cgi-script that executes pstree and
echos/prints the output to the webpage ..

Clearly I am doing it wrong, as it will not work. 

Here's my code:


import os
cmd = "pstree"
status = os.system(cmd)
print "Status:", status

When I run it .. I get the following error from Apache:

[Wed Jun 16 01:18:14 2004] [error] [client] malformed
header from script. Bad header=init-+-5*[agetty]: hello.py

When run from the python intepreter its clearly working:

[drachenfels][~/Desktop]$ python hello.py 
     |          |-kblockd/0
     |          |-2*[pdflush]
     |          `-reiserfs/0
     |                               `-gnome-session
Status: 0

I suspect there's something wrong with the way I am outputting .. as the
first line of the program's output is being fed directly to apache by
the looks of it, which is righlty getting very confused. 

How can I make this work out?

-------------- 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/20040616/156859a4/attachment.bin

More information about the Tutor mailing list