Shell directive not working

$ cat tmp.sh
#!/tools/bin/bash
echo $BASH_VERSION
$ cat tmp.pl
#!/usr/local/bin/perl
use strict;
use warnings;
use DBI;
use CGI;

system("tmp.sh");
$ tmp.sh
3.2.48(1)-release

The result is as expected.

$ tmp.pl
3.2.25(1)-release

The result is not as expected.
The shell directive in tmp.sh does not work.
Can anybody tell me why?
How to correct it?
Thanks.

So try:

$ cat tmp.pl
#!/usr/local/bin/perl
use strict;
use warnings;
use DBI;
use CGI;

system("tmp.sh", "");
1 Like

I don't see how that can possibly make a difference. Whether perl or /bin/sh execs the script, it is the exec(2) syscall that will load the interpreter; in both cases, it will be the same, /tools/bin/bash.

Did I miss something there?

Regards,
Alister

For some reason, the perl script loads a different version of bash than the shell script.

Yes there is something very strange on that server, I wonder what result the OP would get from:

$ /bin/sh -c tmp.sh
$ /bin/sh -c tmp.sh
3.2.25(1)-release

I also found another way to solve the issue.

$cmd="/tools/bin/bash -c 'tmp.sh a b c'";
system($cmd);