[FRPythoneers] popen

Rob Riggs rob at pangalactic.org
Tue Jun 17 16:55:00 MDT 2003


http://www.python.org/doc/current/lib/popen2-flow-control.html

You need to ch.tochild.close() before you ch.fromchild.read().

Cary Miller wrote:

>Hello pythoneers,
>   My ultimate goal is to run an ssh session programatically.  So I want 
>to open a pipe and read/write from/to it.  I can write but when I read 
>the session hangs.  Here is an example using cat instead of ssh.
>
>  
>
>>>>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.
>
>It must be something very simple but I am stumped.  What am I missing?
>
>  
>





More information about the FRPythoneers mailing list