我在Linux Mint上。
我有一个名为samtools的程序,它存储在桌面上的文件夹中。我已经将可执行文件的路径添加到$ PATH变量中。换句话说,我的本地〜/ .bashrc文件中有一行:
export PATH="~/Desktop/samtools/samtools-1.1:$PATH"
名为samtools的可执行文件在此文件夹中。
因此,当我尝试从命令行(如简单命令)启动它时,只需键入“ samtools”即可。当我在命令行中键入可执行文件的直接路径时,它也起作用。
但是,当我尝试从shell脚本启动它时,它不会启动,并说没有找到这样的文件或目录。
实际上,我正在尝试使用另一种使用一些Shell脚本预处理某些数据的软件。我得到的错误看起来像这样:
Indexing...
./RD_capture//process_one_capture.sh: 17: ./RD_capture//process_one_capture.sh: samtools: not found
Sorting...
./RD_capture//process_one_capture.sh: 20: ./RD_capture//process_one_capture.sh: samtools: not found
Piling up...
./RD_capture//process_one_capture.sh: 23: ./RD_capture//process_one_capture.sh: samtools: not found
Shell代码如下所示:
echo "Indexing..."
samtools index $INPUTDIR/$sample.bam
#Then we sort them
echo "Sorting..."
samtools sort $INPUTDIR/$sample.bam $TMPDIR/$sample.sorted
#Finally we pile them up
echo "Piling up..."
samtools mpileup $TMPDIR/$sample.sorted.bam | cut -f 1-4 > $OUTPUT/$(basename $sample .bam).pile
谁能帮我解决这个问题?
看来Linux无法找到samtools
。
解决此问题的方法:在开始时声明此问题(更改pwd
从导致可执行文件的路径pwd
)
export set CURRENT_DIR=`pwd`
并在调用samtools时使用
$CURRENT_DIR/samtools
注意1:当shell脚本从执行时,您有责任告知shell脚本的确切路径/usr/bin/sh
。尝试使用命令在控制台上回显路径,如果这样做没有帮助,如下所示:
echo `pwd`
注意2:上方反引号的使用位于键盘左上角。
注3:在export set
使用全局变量存储在一个shell脚本,所以这个命令后出现的命令可以使用这个变量和以往任何时候都需要的时候对其进行更新。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句