Was Re: need wrapper for ssh/scp

Nick Maclaren nmm1 at cus.cam.ac.uk
Fri Apr 7 07:35:09 EDT 2000


In article <20000407130942.E13830 at xs4all.nl>, Thomas Wouters <thomas at xs4all.net> writes:
|> On Thu, Apr 06, 2000 at 09:19:32PM +0000, Andrew McDowell wrote:
|> 
|> > I also working with ssh to execute some remote commands on different
|> > servers.  I'd previously been hobbling together this strange idea of
|> > generating an Expect script in python then running it. (*bleh*)  So once I
|> > saw was clued onto the pty module I started playing with it.  Well...I'm
|> > either severely confused, or something isn't working properly.  Could anyone
|> > offer some help?
|> 
|> Help is easiest if you also explain what the problem is ;) I already see one
|> problem though: you read the password with 'string.strip(raw_input())',
|> which means the terminating newline gets stripped off the password, but you
|> dont supply it with os.write(), which means ssh thinks there is more
|> password to come, and patiently sits waiting for it, untill you brutally
|> kill it ;)
|> 
|> In your real app you probably want to use select(), by the way, before
|> attempting to read something. Doing a read() when there's no data to be read
|> makes a blocking read, which can lead to deadlocks. See telnetlib for some
|> examples on how to use it.

If you are trying to write a reliable application, be aware that this
area is a minefield.  select is not in POSIX, and therefore has no
specification - it does subtly different things on different Unices.
The same is regrettably true for the detailed semantics of read and
write, such as what happens on failures and how (non)blocking modes
work on network connexions (such as sockets.)


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1 at cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



More information about the Python-list mailing list