Help with Popen3 objects and ssh... Python 2.x

Andrew MacIntyre andymac at bullseye.apana.org.au
Sat Apr 21 00:09:36 EDT 2001


On Fri, 20 Apr 2001, Gilles Lenfant wrote:

> Thanks Andrew but I still got problems with or without '\n' after the
> password.
>
> Seems that flows returned by popenx('ssh...') don't connect with
> stdin/stdout/stderr on the remote machine.
> I'm still trying to get something working when my partner does not want to
> have a telnet daemon on his remote host such I can use 'telnetlib'.
> Is there somewhere an 'sshlib' ?

One thing that occurs to me is that you perhaps should explicitly close
the write pipe after sending the password (and before the wait() call), as
that may be holding the child process in suspension.  You could check this
with ps or top.

Another is that you may be better off just issuing the read(), and using
wait() after the read() if you really must know the exit status.  It is
possible that having the child reaped might be dumping the pipe.

ie:
  tochild.write('password\n')
  tochild.close()
  r = fromchild.read()
  fromchild.close()    # optional AFAIK
  s = wait()

I'm not aware of an sshlib module (have you checked the Vaults of
Parnassus?), although it is possible to build the socket module with SSL
support so it probably wouldn't be too hard (just tedious) to write.

--
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andrew.macintyre at aba.gov.au    (work) | Snail: PO Box 370
        andymac at bullseye.apana.org.au  (play) |        Belconnen  ACT  2616
        andymac at pcug.org.au           (play2) |        Australia





More information about the Python-list mailing list