[Tutor] Running a dos program with python
Wayne Werner
waynejwerner at gmail.com
Wed Mar 10 23:59:52 CET 2010
On Wed, Mar 10, 2010 at 4:51 PM, Armstrong, Richard J. <
rarmstro at water.ca.gov> wrote:
>
>
> The dos program pops up and if I hit the enter key three times then it
> runs. How can I add these three “enters” into the script?
>
I'm not at all sure if this way would work, but you could send the \r\n
through a pipe:
p = subprocess.Popen([file1, file2, file3], stdin=subprocess.PIPE)
p.communicate("\r\n\r\n\r\n") # Three windows line ending sequences.
it also may be possible to add them to the end of the last parameter:
'b.txt\r\n\r\n\r\n'
I don't have much faith that it will work, but you can certainly try!
HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100310/297f78e2/attachment.html>
More information about the Tutor
mailing list