Bash Scripting Project exercise 2

Does anybody know why, when I run my script I am getting ‘Permission Denied’. So far all I’ve entered is the shebang line and the initial echo statement. Grateful for any pointers.
Cheers
Lud

the most obvious thing to do would be to check the permissions:

ls -l script.sh
2 Likes

Thanks for your reply, when I run the above command I get:
$ ls -l script.sh -rw------- 1 ccuser ccuser 63 Oct 16 11:50 script.sh

Which from my understanding means I have read and write permission, but doesn’t seem like I can run the file, which is the error I keep getting.
Have I missed something in the instructions, am I required to change the permissions to allow me to run this?

Anything you want to run/execute will need executable permission (x). You will need to add the permission:

chmod o+x script.sh

or:

chmod 700 script.sh

the first command adds executable permission (x) for owner (o)

the second sets all permission explicitly.

3 Likes

I’ve tried both commands and the second command works.
Thanks for your assistance
Cheers

I just asked the same question and received this reply which has solved the problem -

If you give permission using bash it should resolve!