I'm writing a Python program to call a local binary with Popen to capture its output. I change directories to it with os.chdir
and I have verified the file is there. However, the following code raises a 'file not found' exception.
Can anyone tell me what I'm doing wrong? Is there something special I have to do with running programs from directories not in my $PATH? Thanks in advance.
try:
os.chdir('/home/me')
p = sub.Popen(['./exec', '--arg', 'arg1'], cwd=os.getcwd(), stdout=sub.PIPE)
out, err = p.communicate()
print("done")
except OSError as e:
print("error %s" % e.strerror)