ruby - Printing ssh output to screen -
i've been working on script remotely run ruby script on server using net/ssh , print output screen can see what's going on , i'm there has answered questions here. thanks!
right prints output prints commands, /opt/scripts/test_run.rb , exit, several times screen first , output of script. see commands run once , output of script screen. doing wrong? in advance!
#!/usr/bin/ruby require 'net/ssh' require 'pty' puts "running test" net::ssh.start(server, user) |ssh| ssh.open_channel |channel| channel.on_request "exit-status" |channel, data| $exit_status = data.read_long end channel.request_pty |channel, data| channel.exec("sudo -s") channel.on_data |channel, data| puts data channel.send_data("/opt/scripts/test_run.rb\n") channel.send_data("exit\n") end end end end puts "done" puts `sleep 5` puts " " puts "end of test"
Comments
Post a Comment