Running External Programs from Within Python
Nuff Said
nuffsaid at phreaker.net
Sat Jan 31 16:50:52 EST 2004
On Sat, 31 Jan 2004 11:23:42 -0800, Bob=Moore wrote:
>
> Can I run (call? exec? eval?) an external program from inside a Python
> program?
>
Check out os.popen (in all it's variants); e.g. something like
the following will do what you want:
import os
stdin, stdout, stderr = os.popen3('your program goes here')
output = stdout.read()
errors = stderr.read()
stdin.close(); stdout.close(); stderr.close()
... do something with 'output' and 'errors' ...
HTH / Nuff
More information about the Python-list
mailing list