0

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.

Community
  • 1
  • 1
user1343318
  • 2,093
  • 6
  • 32
  • 59

1 Answers1

0

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.

Ivan Lebediev
  • 507
  • 4
  • 15