[Tutor] Connecting to interactive program

Alan Gauld alan.gauld at freenet.co.uk
Tue Dec 7 23:33:50 CET 2004


> Has anyone ever tried to send commands to a running interactive
python
> session from, say, the command line or another app?

This isn't too hard if you use stdin/stdout. But it does depend on
what you mean by send commands from the command line. If the process
is a daemon for example and it isn't stopped waiting for input then
its going to be hard! If its waiting on a socket then its a standard
ipc issue.

> If so, please let me know how you achieved this.

Assuming you mean something that normally interacts with a human
user then you can use things like expect to simulate user input.
Is that what you mean?

Alan G.



More information about the Tutor mailing list