I've got a program that calls a shell script from python. In the shell script, I add to the LD_LIBRARY_PATH like so, pointing at the .so's from mdbtools.
NEWPATH=${PWD}"/mdbtools/usr/lib/x86_64-linux-gnu"
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NEWPATH
I'm pretty sure this part of the code is correct. I then call one of the programs from the .so, "mdb-export" like so, using variables from the input. :
mdb-export ${1} Athlete > "${2}athlete.csv"
Here's the confusing part. When I call the script from the commandline
./buildscvs abcd.mdb 1234
it works perfectly. The csvs are populated as expected. However, when I call the script from python:
try:
p = Popen([cmd, filename, prepend], stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True).communicate()[0]
print "p", p
except Exception as e:
print str(e)
cmd, filename, and prepend are as follows
filename = /app/djangoFiles/meetPlanner/2011ROXBURY.mdb
cmd = /app/djangoFiles/meetPlanner/buildcsvs.sh
prepend = 824365891
The csvs come out blank. This seems consistent with what happens when you run a command with an unknown program name, like if I ran
abcd 1234.mdb > test.csv
Does anyone have any idea what's going on? I'd very much appreciate any help you can give me
Thank you!
EDIT
After changing to subprocess.check_call()
as suggested below, I now get the following error message:
/mdb-export: error while loading shared libraries: libmdb.so.2: cannot open shared object file: No such file or directory