I have a script which calls some other bash, python, and ruby scripts. The script is similar to the following:
#!/bin/bash
set -x
./aux1.py
./aux2.sh
When I run the script from the command line, it runs but it gives me the following output:
./script.sh: line 5: ./aux1.py: Permission denied
The aux.py
script has #!/usr/bin/env python
at the top; when I call it from the command line with ./aux.py
it is fine, however when called from this script in the exact same way I get this error. The strange part is that this only happens when I run the script with ./script.sh
; when I run the script with bash script.sh
the auxilliary scripts work perfectly.
I'm using Linux, why does this happen?
Update, 3 March 2014
There's nothing conflicting in the PATH
, and all of the scripts are chmod +rx
. uname -srvmo
gives
Linux 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Dec 13 06:58:20 EST 2013 x86_64 GNU/Linux
and there's no more information available in uname -a
. SELinux is enabled, but I'm not an administrator so I can't access that information.
Before launching the main script you must be sure that all the subscripts have got the right permissions. In particular you are interested in the permission for you (your user and owner of the files) to execute the file. This is a short tutorial on permissions. http://blog.pluralsight.com/linux-file-permissions http://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions
If this is the problem (and it look so), the simpler solution is to run the following commands
To check whether you have permission to execute simply run
You should see something like
where you should see a "x" in the 4th column corresponding to the file.
Maybe type
sudo su
before running your script so that you are the root user. When the script completes simply typeexit
to get out of root. Typeexit
again to close the shell.:D