[NTLUG:Discuss] Why does nfs wreck shell scripts?

Rick Cook rcook at ntlug.org
Wed Aug 21 23:47:27 CDT 2002


On Wednesday 21 August 2002 22:26, Lance Simmons wrote:
> I'm playing around with nfs at home. When I've got a bash script on
> an nfs-mounted filesystem, I can't execute it directly. Consider this
> script, named "test":
>
>  #!/bin/sh
>  echo "test"
>  exit 0
>
> When I try to execute test directly (./test), I get this error:
>
>  bash: ./test: /bin/sh: bad interpreter: Permission denied
>
> When I try to execute test with the command "sh ./test", it works.
>
> Can someone knowledgeable about nfs explain what this is about? I
> imagine it's something pretty simple. I'm probably misunderstanding
> the metaphysics of nfs, but I'm not sure where to look.


I made the "test" script named "script" and performed the following 
test=>

rcook at p7300:/mnt$ sudo chmod -x /bin/sh
rcook at p7300:/mnt$ ./script
bash: ./script: /bin/sh: bad interpreter: Permission denied
rcook at p7300:/mnt$ sudo chmod +x /bin/sh
rcook at p7300:/mnt$ ./script
test
rcook at p7300:/mnt$ df .
Filesystem           1K-blocks      Used Available Use% Mounted on
g4dual:/tmp           20642432  11684192   7909664  60% /mnt


(On my machine, /bin/sh is a symbolic link to bash. chmod -x is probably 
not a good idea)


As you can see, I could replicate your behaviour by denying execute 
permission to /bin/sh. In my case, however, this means that "sh ./test" 
is also broken.


Rick




More information about the Discuss mailing list