linux - Executable lauches if called directly from terminal, but does not work when called from shell script
I have downloaded some software (called samtools
) and it is stored in a folder on my desktop. Then I've added the path to the executable into the PATH
environment variable. In other words my ~/.bashrc
file has the following line:
export PATH="~/Desktop/samtools/samtools-1.1:$PATH".
The executable file named samtools
is in this folder.
When I try to launch it from the command line by simply typing samtools
, it works. It also works when I use the full path to the executable.
However, when I try to launch it from a shell script, it does not launch and reports either: No such file
or Directory not found
.
Can anyone help me to solve this problem?
EDIT: As some people requested.
The exact error message is:
Realigning using Bowtie2...
./RP_capture//realign/filter_long_inserts.sh: 29: ./RP_capture//realign/filter_long_inserts.sh: samtools: not found
./RP_capture//realign/filter_long_inserts.sh: 29: ./RP_capture//realign/filter_long_inserts.sh: samtools: not found
Could not locate a Bowtie index corresponding to basename "./aux/chr1.fa"
I have also added echo $PATH
to my script and the output seems correct. Path to samtools is there.
this is example of one of many calls to samtools from the script.
samtools index $OUTPUT/realignments/$file.abnormal.realign.bowtie.bam
I have actually managed to solve the problem using
export set SAMTOOLS_DIR="/home/laba/Desktop/samtools/samtools-1.1"
within a script and then calling samtools like this:
$SAMTOOLS_DIR/samtools [parameters]
Strangely enough, another binary script calls works with just explicitly providing path to the executable. Without having to use set
.
Answer
Setting directory variable like this:
export set SAMTOOLS_DIR="/home/laba/Desktop/samtools/samtools-1.1"
And then calling the exacutable from the script like this:
$SAMTOOLS_DIR/samtools [parameters]
solves the problem
Comments
Post a Comment