Hi,
How can I call an external program with a python script and retrieve the output and return code?
Hi,
How can I call an external program with a python script and retrieve the output and return code?
Look at the subprocess module: a simple example follows...
from subprocess import Popen
process = Popen(["ls", "-la", "."], stdout=PIPE)
exit_code = os.waitpid(process.pid, 0)
output = process.communicate()[0]
HTH
Check out the subprocess module here: http://docs.python.org/library/subprocess.html#module-subprocess. It should get what you need done.