Cannot start jboss remotely in ruby (Net::SSH)
- by Jared
I am trying to start/stop jboss remotely with ruby Net::SSH library.
I am able to stop jboss with the following code:
require 'net/ssh'
Net::SSH.start('xx.xx.xx.xx', 'jboss', :password => "jboss") do |session|
session.open_channel do |channel|
channel.request_pty(:term => 'xterm') do |ch, success|
raise "could not request pty!" unless success
channel.exec "/etc/init.d/jboss_new stop\n"
end
puts "shell opened"
channel.on_data do |channel, data|
puts data
sleep 1
if data =~ /Password: /
sleep 2
channel.send_data("jboss\n")
end
end
end
end
But when I substitute stop with start I get nothing in return, jboss is not started. I changed password to invalid and get a response
su: Authentication failure
Is there any gimmick here? Can you please advise what is wrong?