Python,使用Popen提交qsub作业

2024-04-16 06:01:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我必须使用qsub(SGE)编写一个python脚本来提交作业。你知道吗

我要执行的命令的格式如下:

qsub -b y /usr/bin/L2prod filein fileout

其中L2prod是一个编译程序(一个二进制文件,这是-by选项的原因),filein/fileout只是带有输入/输出文件名的字符串。 如果我打开一个shell并键入前一行,一切都会很顺利。你知道吗

在我的python程序中,我有:

... 
 args=['qsub -b y ', L2prod, filein, fileout] 
 log.info('executing: '+' '.join(map(str,args)))
 process=subprocess.Popen(args,shell=True)
...
etc.

日志文件中的输出为:

INFO:job_submit:executing: qsub -b y /usr/bin/L2prod /data/L1/20180414-222503_L1.txt /data/L2/20180414-222503_L2.txt

查看日志,命令行似乎是正确的,但我发现以下错误:

qsub: command required for a binary job

没有提交任何作业。你知道吗

似乎在.Popen()方法中忽略了“-b y”选项。我做错什么了?我以为shell=True选项可以解决这个问题。你知道吗


Tags: 文件truebinusr选项作业argsjob
1条回答
网友
1楼 · 发布于 2024-04-16 06:01:51

必须将每个标志作为列表的单独字符串元素提供。第一行是不同的。你知道吗

# args=['qsub -b y ', L2prod, filein, fileout]
args=['qsub', '-b', 'y', L2prod, filein, fileout] 
log.info('executing: '+' '.join(map(str,args)))
process=subprocess.Popen(args,shell=False)

为什么应该避免使用shell = True参数。你知道吗

https://medium.com/python-pandemonium/a-trap-of-shell-true-in-the-subprocess-module-6db7fc66cdfd

相关问题 更多 >