threads, periodically writing to a process
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

threads, periodically writing to a process

From: Adam Monsen <haircut@gmail.com>
Date: Fri Sep 30 2005 - 07:51:59 CEST

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/
Received on Sat Oct 15 03:59:03 2005