I have a question about how to execute the perl file inside of a shell script
I have 2 files now, "test.sh" and "test.pl", here are example of my scripts
SHELL script
#!/bin/bash
perl FILEPATH/test.pl
......
PERL script
#!/usr/bin/perl
my $a = "hello"
sub saysomething
{
print $a;
}
.....
The way I call the shell script is : under the path of shell scripts, execute "./test.sh"
All mentioned above are working under the environment GUN bash, version 4.2.24(1)-release (i686-pc-linux-gnu) + perl (v5.14.2)
But if I put those scripts on server (which I couldn't change the bash / perl version) GNU bash, version 4.2.10(1)-release (x86_64-pc-linux-gnu) + perl (v5.12.4), I got the followign message:
FILEPATH/test.pl: line 2: my: command not found
Does anybody know how can I solve this problem?
BTW, if I execute the perl script individually (perl FILEPATH/FILENAME.pl), it works perfectly.
FILEPATHan absolute or relative path? Should be absoluteFILEPATHsupposed to be an environment variable? If so, then it should be$FILEPATH.#!/usr/bin/perl? If you're going to show us code, it's best to copy-and-paste it; if you re-type it, you risk losing vital information.perlinperl FILEPATH/test.plcan be 'lost'. For example, you might have${PERL-perl}instead of justperl(or the better${PERL:-perl}), or you havealias perl=''or something equally weird? The error you're seeing indicates that the shell is executing the file, not Perl. And the only way I can see for that to happen is there's some hidden change to the code.