running a simple command line tool

Avi Greenbury lists at avi.co
Thu Feb 23 11:45:26 UTC 2012


On Thu, 23 Feb 2012 11:35:52 +0000
Steve Flynn <anothermindbomb at gmail.com> wrote:

> On 23 February 2012 11:16, CJ Tres <ctres at grics.net> wrote:
> 
> > Running basic smoketest.
> > smoketest.sh: 12: [[: not found
> > smoketest.sh: 18: [[: not found
> > smoketest.sh: 26: function: not found
> > Error found.  Leaving run.11199 in place.
> > Unable to execute command: 'sh test.sh'
> 
> [...]
> Have a look at the first line of this script - it'll begin with a hash
> bang (#!) followed by the name of the shell which should be used to
> interpret the script.

Because it's being invoked by being passed as an argument to the
interpreter ('sh test.sh') it doesn't much matter what the shebang says
- it's parsed as just another comment. 

The problem is that it's being passed to sh which is probably dash (and
patently not bash), rather than the bash the developer intended.

For example:

[avi at linear test.d]$ cat test.pl 
#! /usr/bin/perl
print "I'm a perl script\n";
[avi at linear test.d]$ ./test.pl 
I'm a perl script
[avi at linear test.d]$ bash test.pl 
test.pl: line 2: print: command not found
[avi at linear test.d]$ 

-- 
Avi




More information about the ubuntu-users mailing list