【发布时间】:2013-10-18 06:28:15
【问题描述】:
我写了一个 bash 脚本,我收到了这些消息:
/home/myname/documents/myscripts/run_tearingmode.sh:第 44 行:mpirun2:找不到命令:
这里是脚本的相关部分
if [[ "$run_jobs" == "y" ]]
then
printf "The jobs run one after the other. Have fun with the analysis. \n "
for ((i=1;i<=$number_subfolders;i++))
do
sub_folder=${main_folder}_$i
cd
cd gkw/run/${main_folder}/$sub_folder #change into certain subfold
pwd
mpirun2 -np 8 ./gkw_btppx-gnu-DP_3481.x #run on all 8 frames #line 44 Here is the problem
cd
done
fi
我的问题是,当我在某个文件夹中输入该行作为命令时,程序运行正常。这向我表明我正确地实现了它。使用 pwd 我也知道我在正确的文件夹中。 我没有发现我在哪里犯了错误。我需要在脚本中使用某个括号或等效的东西来运行程序吗? 我还删除了命令前面的空白,但没有任何改变。 有什么问题/遗漏了什么?
编辑:问题是,您不能在这样的脚本中从 bashrc 运行别名。 所以我补充说:
mpirun2='/Path/to/mpirun'
到我的脚本并将脚本中的命令更改为:
"$mpirun2" -np 8 ./gkw_btppx-gnu-DP_3481.x #run on all 8 frames
这行得通。 非常感谢。 (不幸的是,我自己不能作为初学者写这个答案:))
【问题讨论】:
-
在脚本运行时检查
PATH环境变量的值(即echo $PATH)。指定mpirun2的完整路径应该会有所帮助。