运行另一个脚本后循环中断Bash脚本

时间:2019-10-19 14:00:09

标签: bash

在循环运行时在bash脚本中运行另一个脚本,但循环中断! N.B.我提到的脚本只是循环当前目录中的文件,然后运行mpirun。 这是我的bash脚本:

#!/bin/bash
np="$1"
bin="$2"
ref="$3"
query="$4"
word_size="$5"

i=1;
input="$query"
while read line; do
echo $line
  if [[ "${line:0:1}" == ">" ]] ; then
    header="$line"
    echo "$header" >> seq_"${i}".fasta
  else
    seq="$line"
    echo "$seq" >> seq_"${i}".fasta
    if ! (( i % 5)) ; then
        ./run.sh $np $bin $ref $word_size
        ^^^^^^^^
        #for filename in *.fasta; do
        #    mpirun -np "${np}" "${bin}" -d "${ref}" -ql "${filename}" -k "${word_size}" -b > log
        #    rm $filename
        #done
    fi
    ((i++))
  fi
done < $input

1 个答案:

答案 0 :(得分:1)

问题是您的[19-10-19 09:30:10.136] Build failed. Build failed. Reason is: 'Build failed with error code 2'. Additional information: [00:00:22.484] [WARN] Command npm failed with exit code 1 Error output: npm WARN tar ENOENT: no such file or directory, open '/private/tmp/builds/_/d793d62e5bf497a40a5438621bbf4ded2170e257/6.0.3/6.0.1/app/node_modules/.staging/@angular/animations-d9761ef9/bundles/animations-browser.umd.min.js.map' npm WARN tar ENOENT: no such file or directory, open '/private/tmp/builds/_/d793d62e5bf497a40a5438621bbf4ded2170e257/6.0.3/6.0.1/app/node_modules/.staging/@angular/core-dbd4e95c/bundles/core.umd.js' npm WARN tar ENOENT: no such file or directory, open '/private/tmp/builds/_/d793d62e5bf497a40a5438621bbf4ded2170e257/6.0.3/6.0.1/app/node_modules/.staging/@angular/router-bd8c3eed/bundles/router.umd.min.js.map' 脚本没有向run.sh传递任何参数。该脚本将变量mpirun传递给${np} ${bin} ${ref} ${filename} ${word_size},但是这些变量在您的主脚本中是本地的,并且在mpirun中未定义。您可以在主脚本中导出这些变量,以便所有子进程都可以使用它们,但是更好的解决方案是在run.sh中使用位置参数:

run.sh