Running External Programs from Within Python

Cameron Laird claird at lairds.com
Sun Feb 1 10:47:23 EST 2004


In article <mailman.1093.1075628924.12720.python-list at python.org>,
RayS  <rays at blue-cove.com> wrote:
			.
			.
			.
>>Do you
>>know at the time you launch the Fortran-coded application
>>all the input it'll need?
>
>Usually not. It's a balance solution routine that requires some interaction 
>from the engineers; the Fortran has a three layer menu, and produces both 
>screen output and files. There is an intermediary result which has to be 
>looked at by the user to decide on the final balance, otherwise I would 
>change the code to just run from arg[] values.
>One of its problems is that there is minimal error checking, and a bad 
>input requires  the user to start over!
> From the popen() docs, it seemed as though Windows could not have both 
>read and write ability over a pipe.
			.
			.
			.
Right.  What you probably want is os.popen2(), which 
<URL: http://python.org/doc/current/lib/module-popen2.html >
documents.  popen() is *not* adequate to your situation.

I write "probably" above only because your description doesn't
make clear to me whether you need your Fortran process's stderr.
If you do, then read through that same reference page to study
popen3() and popen4().

Keep in mind that you're doing something at which Python is 
quite apt.  This kind of wrapping can be fun.  You'll be suc-
cessful.
-- 

Cameron Laird <claird at phaseit.net>
Business:  http://www.Phaseit.net



More information about the Python-list mailing list