Unix Shell - Running a shell script in an NFS-mounted directory

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > December 2007 > Running a shell script in an NFS-mounted directory





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Running a shell script in an NFS-mounted directory
James H. Newman

2007-12-07, 1:29 pm

I have my home directory on a machine A NFS-mounted at a some
mount point in my home directory on a machine B. I have the same username
and user ID in both machines; that is, for all practical purposes the
remote home directory looks just like a subdirectory in B.

Well, not quit. If I try to run a shell script (call it S) that
lives in my home directory in A, while I am logged in at B, I get the
following error:

-bash: ./S: /bin/sh: bad interpreter: Permission denied

Why? Running S from A itself works fine, and it does not contain or
invoke anything not available under B.
Glenn Jackman

2007-12-07, 1:29 pm

At 2007-12-07 11:19AM, "James H. Newman" wrote:
> -bash: ./S: /bin/sh: bad interpreter: Permission denied


Does the #! line contain a (hidden) trailing carriage return?

--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
James H. Newman

2007-12-07, 1:29 pm

On Fri, 07 Dec 2007 16:24:54 +0000, Glenn Jackman wrote:

> At 2007-12-07 11:19AM, "James H. Newman" wrote:
>
> Does the #! line contain a (hidden) trailing carriage return?


Well, this happens for all shell scripts. I have just created a
silly one that reads as follows:

#! /bin/sh

ls -l

I get the error message above when attempting to execute it from the box
that NFS-mounts the directory that contains this shell script.




Glenn Jackman

2007-12-07, 1:29 pm

At 2007-12-07 12:15PM, "James H. Newman" wrote:
> On Fri, 07 Dec 2007 16:24:54 +0000, Glenn Jackman wrote:
>
>
> Well, this happens for all shell scripts. I have just created a
> silly one that reads as follows:
>
> #! /bin/sh
>
> ls -l
>
> I get the error message above when attempting to execute it from the box
> that NFS-mounts the directory that contains this shell script.


What editor do you use?

Try: od -c filename
What do you see after "/bin/sh" ?

--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
James H. Newman

2007-12-07, 1:29 pm

On Fri, 07 Dec 2007 18:31:02 +0000, Glenn Jackman wrote:

> At 2007-12-07 12:15PM, "James H. Newman" wrote:
>
> What editor do you use?


vi. Actually, the elvis variation that ships with Slackware 12.

> Try: od -c filename
> What do you see after "/bin/sh" ?


This is what I get:

0000000 # ! / b i n / s h \n \n l s -
0000020 l \n \n

If I understand it correctly, that second \n after #! /bin/sh is
just a blank line.

Glenn Jackman

2007-12-07, 7:23 pm

At 2007-12-07 01:58PM, "James H. Newman" wrote:
> On Fri, 07 Dec 2007 18:31:02 +0000, Glenn Jackman wrote:
>
>
> vi. Actually, the elvis variation that ships with Slackware 12.
>
>
> This is what I get:
>
> 0000000 # ! / b i n / s h \n \n l s -
> 0000020 l \n \n
>
> If I understand it correctly, that second \n after #! /bin/sh is
> just a blank line.


Yeah, that look correct.

does /bin/sh exist on the "faulty" machine? Is it executable by you?

Next, check the mount parameters, but here you're beyond my competence.


--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
James H. Newman

2007-12-07, 7:23 pm

On Fri, 07 Dec 2007 20:09:54 +0000, Glenn Jackman wrote:

> At 2007-12-07 01:58PM, "James H. Newman" wrote:
>
> Yeah, that look correct.
>
> does /bin/sh exist on the "faulty" machine? Is it executable by you?


Yes and yes.

> Next, check the mount parameters, but here you're beyond my competence.


Thanks for your feedback anyway.

ianallison1980@gmail.com

2007-12-07, 7:23 pm

On Dec 7, 8:19 am, "James H. Newman" <NewJa...@exicite.com> wrote:

> -bash: ./S: /bin/sh: bad interpreter: Permission denied
>


Whenever I've seen this before, the problem has been that the
filesystem was being mounted as noexec by /etc/fstab or autofs
James H. Newman

2007-12-08, 1:45 am

On Fri, 07 Dec 2007 16:33:22 -0800, ianallison1980 wrote:

> On Dec 7, 8:19 am, "James H. Newman" <NewJa...@exicite.com> wrote:
>
> Whenever I've seen this before, the problem has been that the filesystem
> was being mounted as noexec by /etc/fstab or autofs


Yep, that was it. I actually had to add exec to my options in
/etc/fstab.

Thanks very much.

Bill Marcum

2007-12-08, 1:45 am

On 2007-12-07, James H. Newman <NewJames@exicite.com> wrote:
>
>
> I have my home directory on a machine A NFS-mounted at a some
> mount point in my home directory on a machine B. I have the same username
> and user ID in both machines; that is, for all practical purposes the
> remote home directory looks just like a subdirectory in B.
>

Is it possible that the NFS mounted directory is mounted with the noexec
option? Look in /etc/fstab or look at the output of the "mount"
command.


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com