Thank you for the prompt response. Yeah, I missed out one line at the end of the error, the whole of which is:
Traceback (most recent call last): File "process.py", line 18, in <module> retval = subprocess.call(comd, 0, None, None, outptr, errptr) File "/usr/lib/python2.5/subprocess.py", line 443, in call return Popen(*popenargs, **kwargs).wait() File "/usr/lib/python2.5/subprocess.py", line 593, in __init__ errread, errwrite) File "/usr/lib/python2.5/subprocess.py", line 1135, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory Looking forward to any kind of help or suggestion in this regard. Thanks. On Tue, Dec 23, 2008 at 7:00 AM, Chris Rebert <c...@rebertia.com> wrote: > On Mon, Dec 22, 2008 at 2:02 AM, ANURAG BAGARIA > <anurag.baga...@gmail.com> wrote: > > Hello, > > > > 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. > > > > #!/usr/bin/python > > > > import cgi, string, os, sys, cgitb, commands, subprocess > > import posixpath, macpath > > #file = "x.tar.gz" > > #comd = "tar -xf %s" % (file) > > #os.system(comd) > > #commands.getoutput('tar -xf x.tar.gz | cd demo; cp README ../') > > comd = [\ > > "tar -xf x.tar.gz", \ > > "cd demo", \ > > "cp README ../", \ > > ] > > outFile = os.path.join(os.curdir, "output.log") > > outptr = file(outFile, "w") > > errFile = os.path.join(os.curdir, "error.log") > > errptr = file(errFile, "w") > > retval = subprocess.call(comd, 0, None, None, outptr, errptr) > > errptr.close() > > outptr.close() > > if not retval == 0: > > errptr = file(errFile, "r") > > errData = errptr.read() > > errptr.close() > > raise Exception("Error executing command: " + repr(errData)) > > > > > > but after trying to execute this independently, I get the following error > > which I am unable to interpret : > > > > Traceback (most recent call last): > > File "process.py", line 18, in <module> > > retval = subprocess.call(comd, 0, None, None, outptr, errptr) > > File "/usr/lib/python2.5/subprocess.py", line 443, in call > > return Popen(*popenargs, **kwargs).wait() > > File "/usr/lib/python2.5/subprocess.py", line 593, in __init__ > > errread, errwrite) > > File "/usr/lib/python2.5/subprocess.py", line 1135, in _execute_child > > raise child_exception > > There should be at least one more line in this traceback, and that > line is the most important one. > People will need that line to help you with your problem. > > Cheers, > Chris > > -- > Follow the path of the Iguana... > http://rebertia.com > -- I just want to LIVE while I'm alive. AB
-- http://mail.python.org/mailman/listinfo/python-list