Using telnetlib instead of 'popen2' (was: Re: [Python-Dev] Making popen2 actually work)

Peter Funk
Wed, 15 Nov 2000 08:32:59 +0100 (MET)


Guido van Rossum wrote:
> The trick seems to be to get the subprocess not to buffer its output
> (or input).  There's nothing that Python can do for you here!
> Unfortunately, most programs use stdio for all their console I/O, and
> stdio automatically buffers its output when connected to a pipe... :-(
> If you absolutely, positively have to do this with a program that
> won't unbuffer its output, your only resort would be to use pseudo
> ttys -- but that's quite a different story... :-(

Yes.  But it should be noted here, that sometimes you can avoid the rather
complicated and platform depending handling of pseudo ttys, if you use
the 'telnetlib' module from the Python standard library.  The fine lib
documentation contains a good example ready for cut'n'paste.  Disadvantage:
This only works, if the telnet service is not disabled due to security

Regards, Peter