[CentOS] bash file direct execution

Tue Aug 2 12:58:01 UTC 2005
Will McDonald <wmcdonald at gmail.com>

On 02/08/05, dan1 <dan1 at edenpics.com> wrote:
> This is something interesting. If I run 'ldd', it works.
> Now I copied this script to the / directory and run it again with /ldd. That
> works too.
> Now I have transformed that file into my little echo script:
> #!/bin/sh
> echo testing
> 
> And that works too. So I have now two files (/ldd and /ldd2) which are
> scripts and which contains exactly the same content and which behaves
> differently, from the same directory. One is done from scratch and the other
> is modified from another working script.
> 
> Again each file's contents:
> #! /bin/sh
> echo testing
> 
> The result is the following when executed:
> [root at box /]# ./ldd
> testing
> [root at box /]# ./ldd2
> [root at box /]#

That is unusual. What are you using to edit these files? I seem to
recall one of my users having some weirdness with shell scripts
because the lines weren't terminated properly.

Compare the output from...

$ cat -A /ldd
$ cat -A /ldd2

As JohnL pointed out, strace might be helpful too.

Will.