使用subprocess.Popen顺序执行python脚本
我正在使用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
子流程
对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