romberg at fsl.noaa.gov
Tue Jun 17 16:57:10 MDT 2003
>>>>> " " == Cary Miller <Cary.Miller at uchsc.edu> writes:
> 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
I'm fairly sure that '^D' is not inserting what you think it is. In
fact, I think you would use '\x04' to insert the ASCII control
character for ^D. But... even this does not work on my redhat 8
system. I think this might have something to do with that unicode
nonsense. I was able to get cat shutdown by closing it's standard
input like this:
ch = popen2.Popen4('cat')
ch.tochild.write('\x04') # this did not seem to do it
ch.tochild.close() # but this did
Mike Romberg (romberg at fsl.noaa.gov)
More information about the FRPythoneers