calling an external program and capturing the output
ericcire at gmail.com
Sun Jan 18 19:30:14 CET 2009
Thanks guys. That helped point me int he right direction.
with your advice on the subprocess module I stumbled upon this
for anyone else that might be interested here is the solution. It
simply calls a perl script called add.pl that reads 2 numbers from
stdin and adds them together.
Thanks again for the help.
prog = "./add.pl"
args = "3 4"
app = subprocess.Popen
print "opened " + prog
print "writing \'" + args + "\' to " + prog + " subprocess"
print "wrote \'" + args + "\' to " + prog + " subprocess"
result = app.stdout.read()
result = result.rstrip('\n')
print "received: " + result
and here is the output:
writing '3 4' to ./add.pl subprocess
wrote '3 4' to ./add.pl subprocess
More information about the Python-list