[Tutor] cgi with system calls
mymailinglists at neuf.fr
Tue Dec 14 13:21:34 CET 2004
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"
cmd = "/bin/ps"
status = os.system(cmd)
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?
More information about the Tutor