Newbie: issuing shell commands with mod_python
neil
nospam at nospam.nospam
Wed Apr 3 07:32:10 EST 2002
Hi. I have mod_python installed on a linux, apache server and have got some
of the basic examples from www.modpython.org working ok.
I have built a web form that takes some input and sends it to a python
script. The python script is receiving the posted variables correctly as I
can send them back to the browser no problems.
What I need to do now is issue a command to the shell with the python
script. I have the following code
import os
def main(req):
child = os.popen("/usr/bin/htpasswd -cb /usr/local/apache/users/myfile
name1 passwd1")
data = child.read()
err = child.close()
return data
When I hit this script through a browser I get an internal server error
returned to the browser. There is nothing in my error logs and the following
in the access log
[03/Apr/2002:12:28:23 +0000] "GET /cgi/publisher/makepassword.py/main
HTTP/1.0" 500 596
I am a bit stuck at present as I dont really know which way to go forward.
Could it be something to do with my sys.path settings? If so how do I go
about changing them? Can monitor the shell in the same way as you can with
tail -f on logfiles?
Is this even the right way to issues commands against the shell? Should I bu
running a cgi instead of using mod_python?
Any help/direction/tutorials will be gratefull accepted.
neil
More information about the Python-list
mailing list