[Tutor] permissions problem using subprocess

washakie washakie at gmail.com
Mon Feb 11 00:03:20 CET 2008


Answering my own question here, but for the sake of it... adding:

os.chdir(newpath) 
makes it all work... so we have:

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'
os.chdir(newpath)
cmd=os.path.join(newpath,'a.out')
output=run_cmd(cmd);
-- 
View this message in context: http://www.nabble.com/permissions-problem-using-subprocess-tp15402550p15402849.html
Sent from the Python - tutor mailing list archive at Nabble.com.



More information about the Tutor mailing list