threads, periodically writing to a process

Adam Monsen haircut at gmail.com
Fri Sep 30 01:51:59 EDT 2005


I have a program that, when run, (1) does some task, then (2) prompts
for input: "Press ENTER to continue...", then repeats for about ten
different tasks that each take about 5 minutes to complete. There is no
way to disable this prompt.

How would I go about writing a Python program that would periodically
(say, every 10 seconds or so) send a carriage return--"\r\n" (or
whatever the ENTER key sends)--then exit when the subprocess is
finished?

I guess if I get really into this I'd write something that actually
waits for the subprocess to print "Press ENTER to continue..." to
standard output, *then* sends "\r\n", but extra carriage returns don't
hurt, so the first option is probably viable.

This is probably something that Expect could handle pretty easily, but
I'm just into learning Python for the time being.

--
Adam Monsen
http://adammonsen.com/




More information about the Python-list mailing list