Cannot start jboss remotely in ruby (Net::SSH)

Posted by Jared on Stack Overflow See other posts from Stack Overflow or by Jared
Published on 2012-03-23T11:26:47Z Indexed on 2012/03/23 11:30 UTC
Read the original article Hit count: 221

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about jboss