I've got a larger script that basically uses the same type of code below. The script runs and functions but I don't get output to the screen. How do I get the output of the script that is being executed remotely to show up on the screen I'm running the ruby script from?
#!/usr/bin/ruby
#
require 'rubygems'
require 'net/ssh'
require 'pty'
if ENV['USER'] == 'root'
raise "You can't run this as root"
end
Net::SSH.start(server01, testuser) do |ssh|
ssh.open_channel do |channel|
channel.on_request "exit-status" do |channel, data|
$exit_status = data.read_long
end
channel.on_data do |channel, data|
data
end
channel.request_pty do |channel, data|
channel.exec("sudo -s")
channel.send_data("/tmp/scripts/test.sh\n")
channel.send_data("exit\n")
end
end
end
puts "DONE"