[Tutor] Connecting to interactive program

Robert, Andrew ARobert at MFS.com
Tue Dec 7 20:54:48 CET 2004

Have you considered redirecting input from the terminal session itself?

On Linux, I think you can test against sys.stdin.isatty() and assign a
variable to /dev/tty.

The methodology is similar on Windows but you need to import msvcrt and
grab msvcrt.getche().

Thank you,
Andrew Robert
Systems Architect
Information Technology - OpenVMS
Massachusetts Financial Services
Phone:  617-954-5882
Pager:   781-764-7321
E-mail:  arobert at mfs.com
Linux User Number: #201204

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On
Behalf Of Vincent Nijs
Sent: Tuesday, December 07, 2004 2:38 PM
To: tutor at python.org
Subject: Re: [Tutor] Connecting to interactive program

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

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


On 12/1/04 4:10 PM, "Vincent Nijs" <v-nijs at kellogg.northwestern.edu>

> Hi,
> I am trying to send information from an editor (vim) to an interative
> program (say the Python commandline, R, Matlab, etc.).
> I have tried to connect a named pipe to the interactive program using
> mkfifo. For some reason this doesn't work properly however (<eof>
seems to
> be the first thing sent).
> Could anyone provide a very very simple example where from a terminal
> command line I could send, say, 'x=3' to an open interactive python
> I'd like to have something that works on WinXP and Mac (or Linux).
> Thanks!
> Vincent


Tutor maillist  -  Tutor at python.org

"MFS Relay Service" made the following
 annotations on 12/07/2004 03:00:42 PM
This email communication and any attachments may contain proprietary, confidential, or privileged information.  If you are not the intended recipient, you are hereby notified that you have received this email in error and that any review, disclosure, dissemination, distribution or copying of it or its contents is prohibited.  The sender does not waive confidentiality or any privilege by mistransmission.  If you have received this email in error, please notify the sender immediately, delete this email, and destroy all copies and any attachments.

More information about the Tutor mailing list