Linux ';意外的文件结尾';和';导入函数定义时出错';使用qsub运行shellscript时出错

Linux ';意外的文件结尾';和';导入函数定义时出错';使用qsub运行shellscript时出错,linux,shell,cluster-computing,qsub,Linux,Shell,Cluster Computing,Qsub,我有以下shell脚本: #!/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 当我从自己的命令行运行它时,它工作正常

我有以下shell脚本:

#!/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
当我从自己的命令行运行它时,它工作正常,但当我尝试执行以下操作时:

qsub -q ningal.q -cwd -V -o /homes/queue.out -e /queue.err featureFind_C1-18_20t.sh 
我得到以下错误:

/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'

我不明白为什么在使用qsub时会出现这个错误,但在同一台集群计算机上直接运行脚本时却不会。如何使用qsub运行脚本?

出于某种我不知道的原因,在每行末尾添加分号修复了该问题

最有可能的原因是,如果添加分号会产生影响,则保存文件时使用DOS行结尾(\r\n)而不是POSIX行结尾(\r)。

在/usr/share/Modules/init/bash中注释掉了“export-f module”行

在普通的登录shell中,modules.sh将从profile.d调用 模块命令可用。在非登录shell中,如应用程序 包装器脚本它只需首先获取上述文件的源代码

通常,在应用程序脚本中,在寻源上述文件后,它们再次发出命令“模块加载应用程序/供应商/应用程序”,这意味着额外寻源


参考:-

在使用

qsub -shell no -b yes -cwd -V somescript.bash arg1 arg2 etc
如果您使用它提交另一个bashshell脚本。它产生注释

/bin/sh: module: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `BASH_FUNC_module'
(这是运行在CentOS 6.6上的Sun Grid Engine 211.11)通过简单地将以下内容放在包装脚本(而不是包装脚本)的顶部,就可以解决问题:


就这些

将下面的命令添加到~/.bash_配置文件或~/.bashrc文件中,然后再次注销/登录

unset module
或简单的快速运行命令:
echo "unset module" >> ~/.bash_profile && source ~/.bash_profile

我运行了dos2unix,这没什么区别。另外,我在linux上编写了它,当我在同一个linux集群上运行它而不使用qsub时,它就可以工作了?(这里有同样的问题)。在shell脚本的末尾没有
echo "unset module" >> ~/.bash_profile && source ~/.bash_profile