Search code examples
bashfilepermissionsshexecute

bash permission set to 777 but file execution still denied


I wrote a bash script and am trying to execute it from sh but I am getting a "permission denied error". I set to permissions to 777 but it is still preventing me from executing the file.

# which sh
/bin/sh
# ls -l myscript.sh
-rwxrwxrwx    1 root  wheel  974 Nov  4 09:16 myscript.sh
# ./myscript.sh
zsh: permission denied: ./myscript.sh

Any help would be greatly appreciated.


Solution

  • Not sure what could be the reason but try invoking shell explicitly passing your script as argument/command to the Shell like sh myscript.sh