Hello, <br><br>I am a Python Newbie and would like to call a short python script via browser using a CGI script, but initially I am trying to call the same python script directly through python command line. The script intends to perform a few command line in a pipe and I have written the script (a short one) as follows.<br>
<br>#!/usr/bin/python<br><br>import cgi, string, os, sys, cgitb, commands, subprocess<br>import posixpath, macpath<br>#file = "x.tar.gz"<br>#comd = "tar -xf %s" % (file)<br>#os.system(comd)<br>#commands.getoutput('tar -xf x.tar.gz | cd demo; cp README ../')<br>
comd = [\<br>        "tar -xf x.tar.gz", \<br>        "cd demo", \<br>        "cp README ../", \<br>      ]<br>outFile = os.path.join(os.curdir, "output.log")<br>outptr = file(outFile, "w")<br>
errFile = os.path.join(os.curdir, "error.log")<br>errptr = file(errFile, "w")<br>retval = subprocess.call(comd, 0, None, None, outptr, errptr)<br>errptr.close()<br>outptr.close()<br>if not retval == 0:<br>
        errptr = file(errFile, "r")<br>        errData = errptr.read()<br>        errptr.close()<br>        raise Exception("Error executing command: " + repr(errData))<br><br><br>but after trying to execute this independently, I get the following error which I am unable to interpret :<br>
<br>Traceback (most recent call last):<br>  File "process.py", line 18, in <module><br>    retval = subprocess.call(comd, 0, None, None, outptr, errptr)<br>  File "/usr/lib/python2.5/subprocess.py", line 443, in call<br>
    return Popen(*popenargs, **kwargs).wait()<br>  File "/usr/lib/python2.5/subprocess.py", line 593, in __init__<br>    errread, errwrite)<br>  File "/usr/lib/python2.5/subprocess.py", line 1135, in _execute_child<br>
    raise child_exception<br><br><br>Could someone suggest where am I going wrong and if corrected, what is the probability of this script being compatible with being called through the browser. Thanking you people in advance.<br>
<br>Regards.<br clear="all"><br>-- <br>I just want to LIVE while I'm alive.<br><br><br>AB<br>