Calling external program from within python

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Fri Jul 25 11:28:38 EDT 2008


On Fri, 25 Jul 2008 08:13:55 -0700, oj wrote:

> On Jul 25, 3:44 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
>> Because usually if a program *prompts* the user to enter input (and that
>> was what I read from the OP's post), one has to deal with pseudo
>> terminals, not with stdin/out.
> 
> How does the program writing some text before taking input change how
> it takes input?

It might not write the text before taking input because it is buffered. 
But if the controlling program waits for some text before sending input to
the other program all hangs.

> If it runs in a terminal and takes input from the user via keyboard,
> as in the user types a response and presses enter, it's most likely
> using stdin, in which case subprocess would be perfect.

But buffering messes with the order of inputs and outputs.  Buffering is
different if you "talk" to a real (or pseudo) terminal or to a file or
pipe and the calling program can't influence the called programs buffering
except if it pretends to be a terminal, which pexpect does.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list