Need a Bash file to run a perl script.

This is the Perl file.

#!/usr/bin/perl -w
use strict;

system "fastacmd -s $Q -d $NewQuery -o ./gifiles/$Q.$NewQuery.txt";

I have left alot out to avoid complications when understanding this script. Before using a bash command, the script did work with the variables defined.

Here is the Bash script


#$ -o $HOME/xREPLaunch_$JOB_ID.out

#$ -e $HOME/xREPLaunch_$JOB_ID.err

cd $HOME/Labwork/Dbfiles/results

#$ -cwd

perl xREPredoTop.pl

For some reason I keep getting this error

Can't exec "fastacmd": No such file or directory at xREPredoTop.pl line 78, <IN> line 1.

Really confused to why this is not working.

  • 3
    That's the perl script indicating that it cannot find "fastacmd". The output of the shell command which fastacmd might be handy, or to inspect what $ENV{PATH} contains in the perl script, to see what directories it is looking for things in.
    – thrig
    Aug 20, 2015 at 19:37
  • Post the output of echo "$PATH" and of ls -l /path/to/fastacmd (with the right path to the script). Aug 20, 2015 at 21:48

1 Answer 1


Two possibilities I can think of:

The usual one is that you are running the bash script from something like cron, where your user profile script hasn't run and set up $PATH. In this case you can specify

system "/path/to/fastacmd ...

within the perl script so that it doesn't depend on the path, or you can set the

$ENV{PATH}= "/my/custom/paths:$ENV{PATH}";

inside the perl script, or you can fix the path in the bash script by loading your profile scripts:

source /etc/profile;
source ~/.profile;
source ~/.bash_profile;

But the other possibility is that #!/usr/bin/perl declared in your script is not the same perl as in your PATH. You can check this by saying

which perl

For example, if you say ./xREPredoTop.pl it becomes

/usr/bin/perl -w ./xREPredoTop.pl

but if you say perl ./xREPredoTop.pl it could become

/usr/local/bin/perl ./xREPredoTop.pl

and that one could be configured differently in some way that it changes the path.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .