[Tutor] cgi with system calls
mymailinglists at neuf.fr
Tue Dec 14 14:26:44 CET 2004
no luck I'm afraid.
Also, to make it even more annoying, omitting the os call and going for
import cgitb; cgitb.enable()
print "Content-type: text/plain\n\n"
status = """PID TTY TIME CMD
3649 pts0 00:00:00 su
3652 pts0 00:00:00 bash
5197 pts0 00:00:00 ps
I've already half a dozen other scripts happily querying a database but
this is the first one to have an error outside the usual brain fart stuff.
Kent Johnson wrote:
> Nik wrote:
>> I'm trying to write a python cgi script that can control certain
>> processes on my server, but I'm having some trouble.
>> The script is;
>> import cgitb; cgitb.enable()
>> print "Content-type: text/plain\n\n"
> You may need explicit \r\n here, I'm not sure:
> print "Content-type: text/plain\r\n\r\n"
>> import os
>> cmd = "/bin/ps"
>> status = os.system(cmd)
>> print status
>> which seems straight forward, but I get a server error, and
>> malformed header from script. Bad header= PID TTY TIME CMD:
>> appears in the apache logs. The PID TTY etc indicates it's getting
>> the ps response, but why won't it display (even with text/plain)?
>> Ultimately I'll have the content type as html, and I'm going to
>> preprocess the output of ps so it probably won't cause any problems,
>> but I just don't understand why this isn't working in its simple form?
>> btw, the final idea is to list the processes corresponding to a
>> certain name, and allow users to stop them or create new ones. I'm
>> assuming this should be do-able?
>> Tutor maillist - Tutor at python.org
> Tutor maillist - Tutor at python.org
More information about the Tutor