[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:

#!/usr/bin/python

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 81.104.190.151] 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 
init-+-5*[agetty]
     |-apache2---3*[apache2]
     |-aterm---bash---azureus---java
     |-aterm---bash---su---bash
     |-aterm---bash
     |-aterm---bash---python---pstree
     |-bonobo-activati
     |-devfsd
     |-dhcpcd
     |-epiphany-bin
     |-esd
     |-events/0-+-aio/0
     |          |-kblockd/0
     |          |-2*[pdflush]
     |          `-reiserfs/0
     |-evolution-1.4
     |-evolution-alarm
     |-evolution-womba
     |-gaim
     |-gconfd-2
     |-gnome-panel
     |-gnome-settings-
     |-gnome-smproxy
     |-idle---python
     |-kseriod
     |-ksoftirqd/0
     |-kswapd0
     |-login---bash---startx---xinit-+-X
     |                               `-gnome-session
     |-metacity
     |-metalog---metalog
     |-nautilus
     |-nautilus-text-v
     |-nautilus-throbb
     |-notification-ar
     |-proftpd
     |-sshd
     |-wnck-applet
     |-xchat-2
     `-xscreensaver
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?

Conrad. 
-------------- 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