View Full Version : [ubuntu] scripting path problem?

August 29th, 2009, 10:46 PM
Hi I'm having trouble running scripts from a new partition created on a second hard drive. The permissions for the mounted partition are all mine (my single user). When I try to execute a script from a directory in said partition I get:
as user
bash: ./test.sh: /bin/bash: bad interpreter: Permission denied
as root
sudo: unable to execute ./test.sh: Permission denied

but if I run the same script out of my user directory. It works fine!
I have no problems running utilities out of /bin in that directory so it can't be pathing

I've tried changing the path and home environment variables to include the directory I'm working in but to no avail. I changed fstab to use the UUID of the partition in mounting no dice.
I've mounted the partition under the filesystem root and as a subdirectory of my user account, no help there.
stumped gingoblin:confused:

August 29th, 2009, 11:03 PM
Check the read, write and execute privilege of your test.sh script. It is probably owned by root. You may have to change its access right to run it in your directory.

rwx rwx rwx owner etc...

chmod 777 test.sh

Giving permission every one to run it. You can change it to yours later.

./test.sh in your home directory

August 29th, 2009, 11:50 PM
The permissions for the mount point, directory in which the script resides and the script all belong to me. The script is executable.

August 30th, 2009, 01:40 AM
I have done a while ago, can vaguely remember. When you mount a file system on a directory and try to execute a script you also have specify the path in your home directory.


Let say you have mounted it on /tmp

sudo mount /dev/sda1 /tmp

Then if you want to execute it from /tmp/dev/sda1 you have to ensure that the path is set correctly in your logon profile file.

PATH:/tmp/dev/sda1/test.sh something like that in you profile file.

Find out the path where your test.sh script resides. Then set this path in your logon profile file.

August 30th, 2009, 01:53 AM
Forgot to mention, you also have to execute the logon profile file
in your home directory for changes to take effect using a command like


But I don't know exactly what they call this file in Linux.

PATH=/your shell script's path


Then try to execute your file.

August 31st, 2009, 05:32 PM
I think I have a workaround for this problem. It seems to work but i can't explain why. If I execute the script via "./" I get the error. If I execute the script by explicitly invoking bash, as in "bash test.sh" it works! Thanks to all those who assisted me in arriving at a solution.

September 3rd, 2009, 08:00 PM
DOH! When you mount the partition in fstab be sure to mount it "exec"