Executing an external program in Python…
There are several ways of executing an external program from Python, but I had
the problem to catch the standard output.
After a while I came to the following solution:
import os # Executing a shell command mycmd = "python mycode.py" child_stdin, child_stdout, child_stderr = os.popen3(mycmd) # Reading the output streams my_output = child_stdout.read() my_error = child_stderr.read() print "my_output:", my_output print "my_error:", my_error
Enjoy,
Rob.