Linux 使用 qsub 运行 shellscript 时出现“意外的文件结尾”和“错误导入函数定义”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10496758/
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
'Unexpected end of file' and 'error importing function definition' error running shellscript using qsub
提问by Niek de Klein
I have the following shellscript:
我有以下shellscript:
#!/bin/sh
cd /sw/local/bin/
export LD_LIBRARY_PATH=/sw/local/lib:/usr/local/Trolltech/Qt-4.7.2/lib:$LD_LIBRARY_PATH
./FeatureFinderRaw -in /homes/JG-C1-18.mzML -out /homes/test_remove_after_use.featureXML -threads 20
It works fine when I run it from my own command line, but when I try to do:
当我从自己的命令行运行它时它工作正常,但是当我尝试执行以下操作时:
qsub -q ningal.q -cwd -V -o /homes/queue.out -e /queue.err featureFind_C1-18_20t.sh
I get the following error:
我收到以下错误:
/bin/sh: module: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `module'
./FeatureFinderRaw: error while loading shared libraries: libOpenMS.so: cannot open shared object file: No such file or directory
/bin/sh: module: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `module'
./FeatureFinderRaw: error while loading shared libraries: libQtWebKit.so.4: cannot open shared object file: No such file or directory
/bin/sh: module: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `module'
./FeatureFinderRaw: error while loading shared libraries: libQtWebKit.so.4: cannot open shared object file: No such file or directory
/bin/bash: module: line 1: syntax error: unexpected end of file
/bin/bash: error importing function definition for `module'
./FeatureFinderRaw: error while loading shared libraries: libQtWebKit.so.4: cannot open shared object file: No such file or directory
/bin/sh: module: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `module'
./FeatureFinderRaw: error while loading shared libraries: libQtWebKit.so.4: cannot open shared object file: No such file or directory
/bin/sh: module: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `module'
I don't understand why I get this error when using qsub, but not when running the script directly on the same cluster machine. How can I run a script using qsub?
我不明白为什么在使用 qsub 时会出现此错误,但在同一台集群机器上直接运行脚本时却不会。如何使用 qsub 运行脚本?
采纳答案by plijnzaad
Also have this problem in a wrapper script that uses
在使用的包装器脚本中也有这个问题
qsub -shell no -b yes -cwd -V somescript.bash arg1 arg2 etc
if you use it to submit another bash shell script. It produces the annonying
如果您使用它来提交另一个 bash shell 脚本。它产生了令人讨厌的
/bin/sh: module: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `BASH_FUNC_module'
(this is Sun Grid Engine 211.11 running on CentOS 6.6) Turns out things are solved by simply putting the following on top of the wrapper script (not of the wrapped script):
(这是在 CentOS 6.6 上运行的 Sun Grid Engine 211.11)事实证明,只需将以下内容放在包装脚本(而不是包装脚本)的顶部即可解决问题:
unset module
That's all.
就这样。
回答by Niek de Klein
For some reason unknown to me adding semicolons at the end of every line fixed the problem.
出于某种原因,我不知道在每一行的末尾添加分号解决了这个问题。
回答by dj_segfault
Most likely cause is that you saved the file with DOS line endings (\r\n) instead of POSIX line endings (\r) if adding semicolons make a difference.
最可能的原因是,如果添加分号会有所不同,则您使用 DOS 行结尾 (\r\n) 而不是 POSIX 行结尾 (\r) 保存文件。
回答by prabhat kumar
In /usr/share/Modules/init/bash commented out the 'export -f module' line.
在 /usr/share/Modules/init/bash 中注释掉了 'export -f module' 行。
In a normal login shell, modules.sh will be called from profile.d so the module command is available. In a non login shell, like an app wrapper script it just source the above file first.
在普通的登录 shell 中,modules.sh 将从 profile.d 中调用,因此 module 命令可用。在非登录 shell 中,就像应用程序包装脚本一样,它只是首先获取上述文件。
Generally in applications script after sourcing above file they again give command "module load apps/vendor/app" which means extra sourcing.
通常在采购上述文件后的应用程序脚本中,他们再次给出命令“模块加载应用程序/供应商/应用程序”,这意味着额外的采购。
Reference::- http://gridengine.org/pipermail/users/2011-November/002019.html
参考::- http://gridengine.org/pipermail/users/2011-November/002019.html
回答by Cong Nguyen
Add the command below to ~/.bash_profile or ~/.bashrc file then logout/login again.
将下面的命令添加到 ~/.bash_profile 或 ~/.bashrc 文件,然后再次注销/登录。
unset module
或者简单的运行快速命令:
echo "unset module" >> ~/.bash_profile && source ~/.bash_profile