Bash
/home/biol/perl5:是一個目錄
以下腳本崩潰:
#!/bin/bash #usage: sh oxford_pbs.sh ref.fa AA.fasta hybrid.gff3 cov=50 ide=100 for ((i=70;i<=${ide};i++)); do input=$(basename $(echo ${2} | sed 's|.gff3||g')) #cat <<EOF qsub <<EOF #!/bin/bash -l #PBS -N filter #PBS -l walltime=20:00:00 #PBS -j oe #PBS -l select=1:ncpus=1:mem=30G #PBS -M m.lorenc@qut.edu.au ##PBS -m bea cd \$PBS_O_WORKDIR module load bioperl/1.7.1-foss-2017a r/3.4.2-bioconductor-foss-2017a eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)" agat_sp_extract_sequences.pl --gff ${2}-ide${i}-cov${cov}-best-hit.gff3 -f ${1} -p -o ${2}-ide${i}-cov${cov}-best-hit.AA.fasta EOF done
出現此錯誤:
/var/spool/PBS/mom_priv/jobs/8352088.pbs.SC: line 24: /home/biol/perl5: Is a directory /var/spool/PBS/mom_priv/jobs/8352088.pbs.SC: line 27: agat_sp_extract_sequences.pl: command not found
但是,這兩個命令在命令行上執行沒有任何問題:
> module load bioperl/1.7.1-foss-2017a r/3.4.2-bioconductor-foss-2017a > eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)" > > agat_sp_extract_sequences.pl --help ------------------------------------------------------------------------------ | Another GFF Analysis Toolkit (AGAT) - Version: v0.1.0 | | https://github.com/NBISweden/AGAT | | National Bioinformatics Infrastructure Sweden (NBIS) - www.nbis.se | ------------------------------------------------------------------------------
為什麼 Perl 腳本不在 Bash 腳本中執行?
先感謝您
問題是
$(perl ...)
命令替換將立即完成,因為您已經擴展qsub <<EOF
而不是qsub <<'EOF'
為了${i}
擴展。perl 將輸出可以包含空格的行,例如
PERL_MB_OPT="--install_base \"/home/user/perl5\""
但是當你在最終腳本的執行中評估這些時,它會變成
PERL_MB_OPT=--install_base "/home/user/perl5"
你會錯誤
/home/user/perl5
是一個目錄。最簡單的解決方案是將 perl 推遲到以後:eval "\$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"