argriffi
argriffi at ncsu.edu
Fri Feb 22 18:48:00 EST 2008
What I meant was that there are at least a couple of problems with this line. First, you probably want "output" instead of "ouput". Second, you probably want "read()" instead of "read". If you've already tried those versions then I'm just being dense :) Martha Zimet wrote: > My bad.. I also tried that in my various versions > of the code. Same result. > > On Fri Feb 22 18:39 , argriffi sent: > > >> ouput = os.popen(command).read >> >> >> >> >> >> >> >> Martha Zimet wrote: >> >>> I am attempting to call os.system and os.popen from within >>> a mod_python script and nothing happens. That is, the commands >>> perform no action. I am attempting to use os.system and os.popen >>> to execute wget, and I wonder if there any tricks that I am not >>> aware of. I have been googling and didn't find anything useful. >>> Any assistance would be appreciated. >>> >>> Here is some code where 'update' is called from an HTML form. >>> I have tried both os.system and os.popen with the same result. >>> I read about Popen, rather than os.popen, but that does not >>> seem to exist in my implementation. >>> >>> Thanks in advance. >>> >>> Regards, >>> >>> /martha >>> >>> from mod_python import apache >>> import cgi >>> import pg >>> from cgi import escape >>> from urllib import unquote >>> import sys >>> import os >>> >>> def update(req): >>> >>> # The getfirst() method returns the value of the first field >>> # with the name passed as the method argument >>> host = req.form.getfirst('host', '') >>> user = req.form.getfirst('user', '') >>> password = req.form.getfirst('password', '') >>> >>> # Escape the user input to avoid script injection attacks >>> host = cgi.escape(host) >>> user = cgi.escape(user) >>> password = cgi.escape(password) >>> >>> try: >>> output = '' >>> command = "wget --user %s --password %s >>> http://%s/svn/backend/able1.0/db/db.sql" % (user, password, host) >>> req.write(command) >>> req.write('\n') >>> ouput = os.popen(command).read >>> req.write(output) >>> req.write('\n') >>> >>> except Exception, e: >>> r = sys.exc_info() >>> generator = (str(x) for x in r) >>> newstring = ''.join(generator) >>> req.write(newstring) >>> req.write('\n') >>> >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> Mod_python mailing list >>> Mod_python at modpython.org >>> http://mailman.modpython.org/mailman/listinfo/mod_python >>> >>> > > >
|