473,388 Members | 1,327 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

threads, periodically writing to a process

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/

Sep 30 '05 #1
1 1189
Adam Monsen wrote:
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?


unless the program you're controlling is really odd, you might as well
send a whole bunch of newlines, and leave it to the other program to
read one at a time as it needs them.

to keep things really simple, you can just do:

import os

f = open("input.txt", "w")
f.write("\n" * 100)
f.close()

os.system("someprogram <input.txt")

os.remove("input.txt")

(changing this to use subprocess and a pipe should be straightforward)

</F>

Sep 30 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Simon John | last post by:
I'm writing a PyQt network client for XMMS, using the InetCtrl plugin, that on connection receives a track length. To save on bandwidth, I don't want to be continually querying the server for...
9
by: perchef | last post by:
Hi, I have several files to download and a GUI to update. I know this is a frequently asked question but i can't find an appropriate solution. My Downloader extends threading.Thread and update a...
7
by: Dave Rudolf | last post by:
Hi all. I have a multithreaded little app that I am writing. Periodically, I see messages on my console that read: The thread '<No Name>' (0xa7c) has exited with code 0 (0x0).
6
by: Luca | last post by:
I have a doubt: is it dangerous to create widgets out of the main thread, or it is dangerous to call methods of a widgets out of the thread which created it? or both? TIA Perry
3
by: bygandhi | last post by:
Hi - I am writing a service which will check a process and its threads for their state ( alive or dead ). The process has 5 .net managed threads created using thread.start and each have been...
6
by: RahimAsif | last post by:
Hi guys, I would like some advice on thread programming using C#. I am writing an application that communicates with a panel over ethernet, collects data and writes it to a file. The way the...
35
by: Carl J. Van Arsdall | last post by:
Alright, based a on discussion on this mailing list, I've started to wonder, why use threads vs processes. So, If I have a system that has a large area of shared memory, which would be better? ...
4
by: herman | last post by:
Hi, In my python program, I would to like to spwan 5 threads, for the them for 5 minutes maximum and the continue. Here is my script: threads = for j in range(5): t = MyThread()...
4
by: tdahsu | last post by:
All, I'd appreciate any help. I've got a list of files in a directory, and I'd like to iterate through that list and process each one. Rather than do that serially, I was thinking I should...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.