From: Nathan Halterman Date: 2008-11-06T23:57:35+09:00 Subject: Re: Trying to Use "request_pty" Channel Never Closes Thanks Hugh, I'm not sure how to do an echo command with Ruby SSH while in a console application. The first thing I should see is a text based menu. I am unable to get anything from stdout it seems. When I do the same SSH manually from outside of Ruby, I do get the menu to come up. Additionally when I just do a straight session.exec command to connect to the server and send something, what I send doesn't matter, I can see the menu. This means to me that something is being sent back through stdout, but I can't get it with the code below. So this piece of code never seems to send me back anything. [code] channel.on_data do |ch, data| puts "got data: #{data.inspect}" end [/code] Thanks Again, Nathan Hugh Sasse wrote: > On Wed, 5 Nov 2008, Nathan Halterman wrote: > >> OOOOOkaaaaay. :) >> >> So it turns out that it was a timing issue. I was sending the >> channel.on_data too fast for the UI to process. I added in some sleep >> statements and it worked. > > Pardon the spurious + in my previous example, I started to write it in > the style of a patch to make it clear what I had changed, then thought > that would actually make it more obscure! > > I'm not familiar with Net::ssh, but I suspect there will be a way to > read > from the remote machine as well as write to it. I'd recommend, that if > you have echoing on (you can see what you type) that you try to read > back > what you sent. That way you will have less dependence on "magic" timing > numbers, though you will have to be careful how you match what you get > back, > as is the case when you use Expect. If the system gets loaded and you > have > to wait for the echo, then that's still OK. >> >> Thanks a ton! :) >> -- >> Posted via http://www.ruby-forum.com/. >> > > Hugh -- Posted via http://www.ruby-forum.com/.