I have a bash script that sets up a classpath for accessing a series of JARs (it's tf, the cross-platform, command line tool for Team Foundation Server). The file structure is something like:


A Django server running via Apache starts a new tf process, executing the bash script; however, it can't access the jar files in the /usr/bin/tee-clc/lib folder. It seems likely that there's some sort of "sandboxing" or something similar to here but searching didn't get me very far. I would imagine the reason I can access the bash file is because it's in the path and executable but the JARs are somehow different?

Hopefully not too nebulous of a question: Why can't I access files (even 777'd) from a Bash script executing as the Apache user.


I'm beginning to think it has a great deal to do with Python's subprocess.popen emulating a shell rather than actually using a shell. I don't think specifying the Shell=True parameter is the "fix" but I'm not sure how to get the Bash script to work without an actual shell...

1 Answer 1


What are the directory permissions ?

Apache usually runs as a specific user - as far as I remember "apache" on Centos. You should ensure that apache user can read and execute directory where your files are.

For example you can try this to check if apache can see the files:

sudo -u apache ls -l /usr/bin/tee-clc/tf

Also I suggest to stop doing any bash CGI scripting at least until shellshock vulnerabilities are really fixed.

  • The su - ... fails as the apache user doesn't have a password set. I have tried both chown'ing to apache:apache and 777'ing the directory. Right now it's owned by root:root. Oct 1, 2014 at 15:17
  • try just su apache -s /bin/bash password shouldn't matter.
    – mestia
    Oct 1, 2014 at 15:29
  • As su apache, I can access the files. In the bash script that gets ran, 'ls' shows the root directory but 'ls /' shows nothing... Oct 1, 2014 at 15:33
  • If it were a permissions problem, you'd get a "Permission denied" error, not "No such file or directory".
    – Barmar
    Oct 1, 2014 at 16:09
  • Any idea why ls / returns nothing then? Oct 1, 2014 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.