trouble with select and tochild of Popen3 object

Donn Cave donn at u.washington.edu
Fri Feb 21 14:35:44 EST 2003


Quoth Richard Cook <rcook at llnl.gov>:
| Hi, the below code is supposed to open an ssh connection to a remote 
| machine.  It has been set up so that username and password is not 
| necessary for this connection, but often the ssh asks a yes/no 
| question to which I always wish to answer yes.  The code below is 
| supposed to wait until the tochild is writable and write 'yes' to it. 
| what actually happens is written below.  Can anyone help me figure 
| this one out?  Thanks.

It would be cool if Berkeley sockets and UNIX IPC in general worked
that way, but they don't.  When select tells you that a socket file
descriptor is "writable", it means, you can write to it without worry
that you might block.  Which is more or less always true - whether
anything has actually posted a read on the other end, or not, your
bytes can be written to the channel, and the system will look after
them until they're read up or discarded at close.

You can only tell by reading your input and looking for prompts,
which might work for you.  (Or of course you might be able to fix
your ssh environment.)

The only IPC I've used that worked the way I think you want was the
VMS mailbox, where a read posted to the other end raised an event
flag on your end.  I brought this up with a local UNIX enthusiast
once and he seem deeply disturbed by the idea - not just indifferent,
but like morally opposed to it.

	Donn Cave, donn at u.washington.edu




More information about the Python-list mailing list