Linux – Shell script not running as by “./” but it runs by “sh”

bashbash-scriptingfile-permissionslinuxshell

I am running a script on arm target board as a super user, i.e., as a root user. But the script is not executing if i run it with following syntax

root@freescale$ ./Script.sh 
-sh: ./Script.sh: Permission denied

I already gave the read and execute permissions(+rx) by using chmod command. On executing "ls -l" command I get following attributes

root@freescale$ ls -l | grep Script.sh
-rw-rw-rw-    1 root     root          362 Jul  2 08:47 Script.sh

"x" is not there in the file attributes column, whereas the chmod command executed successfully.
On the other hand, this script runs when I run it as

root@freescale$ sh Script.sh 

Can anyone help me to answer this situation?

Best Answer

even if your "chmod" returns success, the execute bit does not really get turned on, as "ls" shows, therefore I conclude something is transparently preventing you from changing the file mode on the filesystem.

what does "lsattr Script.sh" shows?

can you put the script into a ramdrive or another filesystem on the same host and try again?

Related Question