I am using python's subprocess
for executing scripts against a C code base. Concretely, I have a number of scripts that I run one by one against a single instantiation of a program. Here is what I want to do:
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
My current scheme with
myProcess = subprocess.Popen(PATH, BUFFSIZE, STDOUT= myFilePointer ...)
But this fails to yield return output from each execution of process ABC and only records output in case of script 01 and not the rest.
I have looked at official documentation and other resources but cannot find.
Try this:
cmd = subprocess.Popen("ABC %s" % command,
stdout=out,
stderr=subprocess.PIPE)
stdout, stderr = cmd.communicate()
retcode = cmd.returncode
Use command parameter to pass command line argument to ABC. After execution of Popen output from ABC will be stored in stdout . Error that might occur are stored to stderr .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.