I'm on a Centos server and when I tried to run
I get the
Permission Denied error even after I tried adding
chmod +x script.sh.
sh script.sh works though.
The script file starts with
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Most probably your script lacks a "shebang". The system tries to read which interpreting program should be executed to run the script. A "shebang" is recognized by the system if it is on the very first line and starts with
#! is a comment otherwise in most scripting languages, so it will not error out if you run it with a specific interpreting program from the command line like so:
$ bash ./script.sh
More information: https://en.wikipedia.org/wiki/Shebang_(Unix)