Reading stdout of Linux instance with Ruby gem net
I am trying to write a script in Ruby with net-ssh. I've got it talking to my Linux ec2 instance with a basic login and execution of "ls":
Net::SSH.start('host', 'user', :password => "password") do |ssh|
# capture all stderr and stdout output from a remote process
output = ssh.exec!("ls")
puts output
end
When I run that, I get the list of files in my home directory. But when I try to used the same exec! method to run a program and display the stdout start screen, it hangs up trying to return the output.
The program is a text-based Blackjack game I wrote in C++ in school. I am thinking this is likely an issue that requires use of Buffer class to read in long strings with several line breaks (there is some ASCII art). There's also a lot of "system('clear')" calls to clear console. I am trying to reproduce the program's execution screen-by-screen on a client console.
This is conceptually a simple service to implement, I just need to know the right classes/methods. Any implementation examples would be useful.
链接地址: http://www.djcxy.com/p/25280.html