Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/63.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
使用subprocess.Popen顺序执行python脚本_Python_C_Python 2.7_Subprocess - Fatal编程技术网

使用subprocess.Popen顺序执行python脚本

使用subprocess.Popen顺序执行python脚本,python,c,python-2.7,subprocess,Python,C,Python 2.7,Subprocess,我正在使用python的子流程对C代码库执行脚本。具体地说,我有许多脚本,我针对一个程序的单一实例逐一运行这些脚本。以下是我想做的: start process ABC execute python scripts 01 against ABC and store output from ABC in file A execute python scripts 02 against ABC and store output from ABC in file B execute python

我正在使用python的
子流程
对C代码库执行脚本。具体地说,我有许多脚本,我针对一个程序的单一实例逐一运行这些脚本。以下是我想做的:

start process ABC

execute python scripts 01 against ABC and store output from ABC in file A

execute python scripts 02 against ABC and store output from ABC in file B

execute python scripts 03 against ABC and store output from ABC in file C
我目前的计划

myProcess = subprocess.Popen(PATH, BUFFSIZE, STDOUT= myFilePointer ...)
但这无法从每次执行过程ABC中产生返回输出,并且只记录脚本01的输出,而不记录其余的输出

我已查看和其他,但找不到。

请尝试以下操作:

 cmd = subprocess.Popen("ABC %s" % command,
                    stdout=out,
                    stderr=subprocess.PIPE)
 stdout, stderr = cmd.communicate()
 retcode = cmd.returncode
使用命令参数将命令行参数传递给ABC。执行Popen后,ABC的输出将存储在标准输出中。可能发生的错误将存储到stderr