[Tutor] pstree cgi-script
gubbs at fudo.org
Wed Jun 16 09:36:12 EDT 2004
> --- Conrad Gavin <gubbs at fudo.org> wrote:
> > 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
> Ok this is an easy one. I also had this problem at first with cgi.
> you need to put
> print "text/plain/n/n"
> in this case at the begining of the script this tells apache to tell
> the browser whats going on. Otherwise apache croaks. If you
> outputing html then type
> print "text/html/n/n"
> The two caraiage returns are important. There you go good luck
That doesnt seem to work either ..
My code now:
cmd = "pstree"
status = os.system(cmd)
I have tried placing print "text/plain/n/n" and the 'html'
varianteverywhere in the program it can feasably go (marked by the ^
above), checked the permissions of the file etc. It still doesnt work,
the same error appears in the log:
[Wed Jun 16 13:15:14 2004] [error] [client 188.8.131.52] malformed
header from script. Bad header=init-+-5*[agetty]: hello.py
I am usingapache-2.0.49-r3, IDLE to write and save my script with and
python-2.3.4. I am then moving it as root to /var/www/localhost/cgi-bin
and chmod 755'ing it and then chmod +x _just_ to be absolutely certain.
It seems to be running tho, as the error is pretty indicative of the
line you suggested not being parsed or being ignored.
This is why I asked really, I found a website that suggested using the
solution you offered but it didnt work ..
I'm pretty much stumped. :(
Could you possibly place a working version on your server I could surf
too? At least then I would be absolutely certain it was a problem with
my end not the method ..
I have confirmed my cgi works:
Sorry to be a bother!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/tutor/attachments/20040616/01800a22/attachment.bin
More information about the Tutor