[Tutor] permissions problem using subprocess

washakie washakie at gmail.com
Sun Feb 10 23:41:24 CET 2008


Hello, 

I'm converting a perl script which calls shell scripts which call fortran
routines into a python cgi that calls fortran directly (well, not yet using
f2py), but using subprocess.popen. Here's my code:

def run_cmd(cmd):
   """RUN A BASH CMD"""
   import subprocess as sub
   p = sub.Popen(['/bin/bash', '-c', cmd],
                 stdout=sub.PIPE, stderr=sub.STDOUT)
   output = urllib.unquote(p.stdout.read())
   return output

newpath='/path/to/program/directory'
cmd=os.path.join(newpath,'a.out')
output=run_cmd(cmd);

The code crashes, and I get this message:
? System Error:
? Permission denied
? OPEN(UNIT=10,...

As output from the FORTRAN a.out program

I know when I do the exact same thing with the shell script called from the
perl script, I have no problems, so there is something strange with
permissions... in both cases they are run as 'nobody'.. the directory is a
temp directory, with permissions set (for debugging) even to 0777.. and
still nothing! Why would python have a problem but not the shell script?

Thanks!
-- 
View this message in context: http://www.nabble.com/permissions-problem-using-subprocess-tp15402550p15402550.html
Sent from the Python - tutor mailing list archive at Nabble.com.



More information about the Tutor mailing list