[FRPythoneers] popen

Sean Reifschneider jafo at tummy.com
Tue Jun 17 16:54:46 MDT 2003

On Tue, Jun 17, 2003 at 04:43:25PM -0600, Cary Miller wrote:
>   My ultimate goal is to run an ssh session programatically.  So I want 

Probably not something you want to do with popen...

>>>> ch = popen2.Popen4('cat')
>>>> ch.tochild.write ('hello')
>>>> ch.tochild.write ('goodbye\n')
>>>> ch.tochild.write ('farewell\n')
>>>> ch.tochild.write ('^D')
>>>> ch.fromchild.read()
>Hangs forever here.

You probably need to close the "tochild" file descriptor instead of
sending "^D" (which in an interactive session will close the stdin to
the child).

Using SSH from a program works fine *IF* you aren't trying to send it a
password.  For various reasons that I won't go into, SSH does things
that thwart simply doing "echo mypasswd".  So, look at using ssh-agent
or ssh public keys without passphrases, or learn about ptys and the pty

 "The only thing more expensive than hiring a professional is hiring
 an amateur."  -- Red Adair,  Oil Well Fire-Fighter
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995.  Qmail, Python, SysAdmin

More information about the FRPythoneers mailing list