0

Here is our test script...

#!/bin/bash
echo "Hello World"

It is on an NFS share that is mounted on a Linux client. If we call the script like this:

./testscript.sh

then we get this:

sh: ./testscript.sh: Permission denied

If we call it like this:

bash ./testscript.sh

then it executes properly. Also, if we run it on the local filesystem, then it executes correctly without the "bash" prepended.

Any way to do this so that the shebang works? By the way, permissions are wide open on this. 777.

Edit 1:

I found the issue.

I had "user" set in the mount options for the NFS mount. Apparently that removes the ability to execute. I changed that and now it seems to be working.

byumark
  • 298
  • 1
  • 6
  • Indeed: `user Allow an ordinary user to mount the filesystem. [...] This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line user,exec,dev,suid).` – deubeuliou May 22 '13 at 21:16

1 Answers1

1

Use the chmod command to set the executable flag:

chmod +x testscript.sh

Then execute it:

./testscript.sh
hek2mgl
  • 152,036
  • 28
  • 249
  • 266