popen and two-way communication

Jeff Shannon jeff at ccvcorp.com
Wed Oct 20 02:48:39 CEST 2004

cmkl wrote:

>You may be interested in the new subprocess module:
>1) PEP:
>   http://www.python.org/dev/doc/devel/whatsnew/node8.html
>2) source code:
>   http://www.lysator.liu.se/~astrand/popen5/
>3) Windows builds (pre Python-2.4):
>   http://effbot.org/downloads/#subprocess

This looks nice, but I suspect that it won't help the O.P.

Admittedly, I haven't tested subprocess.  But interacting with SSH or 
gpg or most other password-requesting programs doesn't work properly 
through pipes.  These programs read directly from the controlling TTY, 
rather than from stdin.  Pipes don't affect the controlling TTY, meaning 
that you'll *still* be prompted for the password. 

In short, some version of (or replacement for) Expect is probably still 
needed.  It is indeed too bad that pexpect won't work on Windows, or 
more accurately that the pty which pexpect relies on doesn't work on 
Windows...  (Fortunately for me, I need to run ssh on Linux, so pexpect 
should serve my purposes just fine.)

Jeff Shannon
Credit International

More information about the Python-list mailing list