Reputation: 14558
I am getting a 'permission denied' error on a script. I already checked all the usual suspects:
x
permissionrwx
to the owner, which is the user I'm using.The script shebang line is #!/bin/sh
which I can execute fine. But that is irrelevant as it is never even parsed. Setting -x
on my current bash session will not show anything else happening other than trying to execute the script.
The error I get is:
$ path/script
bash: path/script: Permission denied
$ _
edit: if i pass the script as an argument, it works fine
$ /bin/sh -x path/script
...script executes...
Upvotes: 2
Views: 10296
Reputation: 44384
Get more information by diving into the kernel calls. It helps if you have a knowledge of C, and the kernel APIs. man
pages are your friends.
See if you have a program called strace
try which strace
. There are similar programs on various UNIXs (like truss
on some Suns, dtruss
on OS X) but strace
is the most common. If you can't find one, Google something like "strace for ....", whatever UNIX you are using.
strace -o strace.out -f /bin/sh path/script
-o strace.out
means trace to the file strace.out
- look at it using an editor
-f
means follow child processes.
/bin/sh path/script
is the program you are tracing.
You will get a lot of output, sometimes it is worth going to the end and working backwards.
On Linux there is also ltrace
which can trace library calls as well.
If the program you wish to trace is already running, then the -p
option, followed by the pid
of the process, can be very handy.
Of course, having said all that it is quite possible in this case that the shell was reporting all that the kernel was telling it. It might be that there was no further information to give.
Upvotes: 4