"/bin/bash -l" 无效选项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17136273/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"/bin/bash -l" Invalid option
提问by Eofet
Well, I am trying to run serial MPI jobs masked as a one job on our supercomputer. The main submission script basically looks like that:
好吧,我正在尝试在我们的超级计算机上运行被屏蔽为一项工作的串行 MPI 作业。主要的提交脚本基本上是这样的:
#!/bin/bash -l
#PBS -l nodes=4:ppn=8,walltime=24:00:00
cat $PBS_NODEFILE | uniq | tr '\012' ' ' > tmp-$PBS_JOBID
read -a NODE < tmp-$PBS_JOBID
rm tmp-$PBS_JOBID
inode=-1
ijob=0
for ((K=1;K<=8;K++))
do
[ $((ijob++ % 2)) -eq 0 ] && ((inode++))
ssh ${NODE[inode]} _somepath_/RUN$K/sub.script &
done
wait
exit 0
Each sub.script looks like:
每个 sub.script 看起来像:
#!/bin/bash -l
#PBS -l walltime=24:00:00,nodes=1:ppn=4
module load intel
module load ompi
export FORT_BUFFERED=1
*run executable*
wait
exit 0
And sometimes I encounter an error for each sub.script (jobs die immediately):
有时我会遇到每个 sub.script 的错误(作业立即死亡):
/bin/bash: -
: invalid option
Usage: /bin/bash [GNU long option] [option] ...
/bin/bash [GNU long option] [option] script-file ...
*etc.*
The most interesting thing is that it is a random error meaning if I run the same script for the second (or 3rd etc.) time it will run without any problems. Sometimes I'm lucky, sometimes I'm not... Removing -l won't help because in that case modules cannot be loaded and mpirun won't work. Any suggestions how to fix it?
最有趣的是,这是一个随机错误,这意味着如果我第二次(或第三次等)运行相同的脚本,它将毫无问题地运行。有时我很幸运,有时我不是......删除 -l 无济于事,因为在这种情况下无法加载模块并且 mpirun 将无法工作。任何建议如何解决它?
Thanks a lot in advance!
非常感谢!
回答by cogsmos
You script probably has characters in it that you cannot see. Perhaps it was copy/pasted using the wrong character set translation or is in DOS format. In the case of the latter you can use the tofrodos or dos2unix package to correct.
您的脚本中可能包含您看不到的字符。也许它是使用错误的字符集翻译复制/粘贴的,或者是 DOS 格式。对于后者,您可以使用 tofrodos 或 dos2unix 包进行更正。
In either case you could pull it up in 'vi' or another application which will usually show weird characters like ^@ or ^M. You could try cat -v filename
which might help see these oddities. Push comes to shove try hexdump (or hd, or od).
无论哪种情况,您都可以在“vi”或其他通常会显示奇怪字符(如 ^@ 或 ^M)的应用程序中提取它。你可以试试cat -v filename
这可能有助于看到这些奇怪的东西。推来推去试试hexdump(或hd,或od)。
回答by Dan
I just encountered this and I had invalid line endings. I changed from CRLF to LF and that fixed it!
我刚刚遇到了这个并且我有无效的行尾。我从 CRLF 更改为 LF 并修复了它!