[Tutor] Replacing keyboard input to EXE file

Tino Dai oberoc at gmail.com
Thu Jun 11 17:05:31 CEST 2009


Hi,

    I know that this is a python group but you might want to try the open
source utility called Expect. It does what you need it to do without having
having to go through this trial and error process with subprocess.
http://expect.nist.gov/

-Tino


On Thu, Jun 11, 2009 at 9:45 AM, eShopping
<etrade.griffiths at dsl.pipex.com>wrote:

>
>  >> eShopping wrote:
>> >>> import subprocess
>> >>> x = subprocess.Popen(args="poly.exe",stdin=subprocess.PIPE)
>> >>> for item in ["polyin.dat", "polyout.dat", "polyout.plt"]:
>> >>>     x.stdin.write('%s\n' % item)
>> >>> but got the same error message
>> >>
>> >> Above code would seem to be correct.
>> >>
>> >> Are you sure the Fortran program accepts the names?
>> >> One easy way to test this is to try
>> >>
>> >> C:\> poly.exe < poly_files.txt
>> >>
>> >> in a CMD program (or COMMAND or whatever the console program is called
>> >> nowadays at Win* systems).
>> >
>> > Tried piping the input as suggested but POLY ignores the pipe and just
>> > asks me for the names of the files as if we were in interactive mode.
>>
>> Can you provide an example of the Fortran program session? Especially
>> the part where it asked for file name.
>>
>
> An example of the session is
>
> =======start of snip
> C:\TEMP>poly
> PLEASE ENTER THE INPUT FILE NAME:
> polyin.dat
> PLEASE ENTER THE OUTPUT FILE NAME:
> polyout.dat
> PLEASE ENTER PLOT OUTPUT FILE NAME:
> polyout.plt
>
> Execution terminated: Normal stop
> C:\TEMP>
> =======end of snip
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090611/cfa5d5cc/attachment.htm>


More information about the Tutor mailing list