Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python编写shell脚本时“未找到命令”_Python_Shell_Sungridengine - Fatal编程技术网

使用python编写shell脚本时“未找到命令”

使用python编写shell脚本时“未找到命令”,python,shell,sungridengine,Python,Shell,Sungridengine,我有一个python脚本: #!/usr/bin/python print 'hi' 我试图将此脚本作为作业发送到计算集群上执行。我将它与qsub一起发送,如下所示:qsub myscript.py 在运行它之前,我执行了以下操作: chmod +x myscript.py 但是,当我打开输出文件时,我发现: Warning: no access to tty (Bad file descriptor). Thus no job control in this shell. print:

我有一个python脚本:

#!/usr/bin/python

print 'hi'
我试图将此脚本作为作业发送到计算集群上执行。我将它与qsub一起发送,如下所示:qsub myscript.py

在运行它之前,我执行了以下操作:

chmod +x myscript.py
但是,当我打开输出文件时,我发现:

Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
print: Command not found.
当我打开错误文件时,我发现:

Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
print: Command not found.
怎么了

编辑:我按照

中的说明进行操作。看起来qsub没有阅读您的行,所以只是使用shell执行您的脚本


这个答案提供了一些关于如何处理这个问题的选项,具体取决于您的系统:

一个选项是将解释器设置为python,如下所示:

qsub -S /usr/bin/python  myscript.py
我确信有一种替代方法可以做到这一点,而不需要-S选项,让SGE在shebang中基于解释器执行代码;但是,此解决方案可能足以满足您的需要

此外,关于这一产出:

Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
忽略这一点似乎是安全的:

编辑:

也适用于:

qsub <<< "./myscript.py"
qsub <<< "python ./myscript.py"

我的想法是避免编写bash脚本文件