trouble with select and tochild of Popen3 object

Richard Cook rcook at llnl.gov
Fri Feb 21 16:52:46 EST 2003


At 7:35 PM +0000 2/21/03, Donn Cave wrote:
>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.)

I think I misspoke.  I actually don't wait for it to be writeable. 
But if you look at the example output I posted, you'll see that it 
does indeed prompt me, and I do indeed write 'yes' to it after it has 
prompted me (in fact, just for kicks, I write 'yes' to it 
constantly).  It just doesn't seem to hear it.
I note that there is an 'exc' argument for select.select that I'm not 
using, should I check for some condition?  I'm not much of a sockets 
programmer, I'm afraid.  It is a bit intimidating to moi.
-- 
Richard Cook  
Lawrence Livermore National Laboratory
Bldg-451 Rm-2043, Mail Stop L-561       
7000 East Avenue,  Livermore, CA, 94550, USA
phone (925) 423-9605 (work)    fax (925) 423-8704
---
Information Management & Graphics Grp., Services & Development Div., 
Integrated Computing & Communications Dept.
(opinions expressed herein are mine and not those of LLNL)





More information about the Python-list mailing list