[CentOS] bash file direct execution

Tue Aug 2 01:26:24 UTC 2005
BRUCE STANLEY <bruce.stanley at prodigy.net>


--- dan1 <dan1 at edenpics.com> wrote:

> >> This script is the following:
> >>
> >> #!bin/sh
> >> CURRENT_IP=`/sbin/ifconfig eth0 | grep inet | cut -d : -f 2 | cut -d 
> >>   -f
> >> 1`
> >> export CURRENT_IP
> >> echo $CURRENT_IP
> >>
> >
> >You need to change the first line to #!/bin/sh
> >
> >Otherwise, the script is looking for a bin directory in whatever current
> >directory you are in. Unless you are at the root of the filesystem, it most
> >likely won't be found.
> >
> >Matt
> 
> 
> Hello, Matt.
> 
> Sorry for that. Yes you are right it is a mistake. However this was only on 
> this script. The problem I described before still remains the same for the 
> other scripts and even on this one once I have corrected it to #!/bin/sh.
> 
> There is simply no output at all for those scripts and no error message 
> neither. And it's also strange that it works when put in the /root directory 
> and not in the /. The /root is on the same filesystem than / and I have 
> verified in the /etc/fstab : the / is mounted with the options: 
> defaults,usrquota,grquota. The 'noexec' option is not set.
> 
> Any other idea ?
> 
> Thanks,
> Daniel
> 
> 

Hi Dan!

The  '/bin/sh' command is usually a symbolic link to  '/bin/bash'.
Check this by   ls -l  /bin/sh   (should show it pointing to bash).

Maybe the link has gotton broken some how.

Change the  '#!/bin/sh' in the scripts to  '#!/bin/bash' and see if
they then execute ok.

If so,  as root,   'rm  /bin/sh' ,  followed by  'ln -s /bin/bash  /bin/sh'
to fix the link.