Using Python to Execute a C or FORTRAN Program (Windows)

Stephen Hansen apt.shansen at gmail.com
Mon Dec 14 21:58:48 EST 2009


On Mon, Dec 14, 2009 at 6:14 PM, W. eWatson <wolftracks at invalid.com> wrote:

> I think Python is capable of executing a compiled C or FORTRAN program, and
> maybe even getting some parameters passed back. Does anyone have a example
> of how this might be done? I'm running under Win XP Pro.
>

import subprocess
proc = subprocess.Popen(r"C:\mydir\myprog.exe", stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
out, err = proc.communicate()

print "Command returned", out

See the subprocess module documentation for details.

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091214/b5920be0/attachment-0001.html>


More information about the Python-list mailing list