Not able to send command to remote computer

Hi

I do automation using Watir, Ruby and some add on’s.

Earlier i have Ruby 1.8.* and my code to send command to linux box is
working fine.

But now i upgraded to Ruby 1.9.2. So i upgraded needle, setsftp and
netssh too.

Now same piece of code is not working, it throws error for on_success.

This is the code in my script :

def issueCommandInKazBox(okMachine="", command="", matchLog="",
user=“admin”, passwd=“kazeon”)
puts " issueCommandInKazMachine=#{okMachine}"
puts " issueCommandInKazcommand=#{command}"
puts " issueCommandInKazstatus=#{matchLog}"
puts " issueCommandInKazuser=#{user}"
puts " issueCommandInKazpasswd=#{passwd}"
tempString = “”
Net::SSH.start(okMachine, user, :password => passwd, :paranoid =>
false ) do |session|

session.open_channel do |channel|
channel.on_success do
puts “shell was started successfully!”
puts “Adding command - #{command}…”
channel.send_data “#{command}\n”
channel.send_data “exit\n” # tell the shell to exit
end
channel.on_failure do
puts “shell could not be started!”
end
channel.on_data do |ch,data|
puts “recieved the following from shell”
puts “#{data}”
tempString = tempString + “\n” + data
end
channel.on_close do
puts “shell terminated”
end
channel.send_request “shell”, nil, true
end
session.loop
end

Are libraries are changed? did we change the syntax for the command?

Im stuck because of this change, my first step is to do send files to
remote computer and execute few commands and then only i can start the
regression suite.

Can some help me for this. Can any one share some info if they know?

Bhavesh

what error message?

It shows error as :

issueCommandInKazMachine=10.10.150.172
issueCommandInKazcommand=show cluster
issueCommandInKazstatus=
issueCommandInKazuser=admin
issueCommandInKazpasswd=kazeon

E
Finished in 1.374964 seconds.

  1. Error:
    test_0001(TC_I18N):
    NoMethodError: undefined method on_success' for #<Net::SSH::Connection::Channel :0x16aa408> C:/IE_AUTOMATION/kazeon/qa/watir-v1_4-TIP/Lib/KazeonCommon/BasicMethodLibrar y.rb:877:inblock (2 levels) in issueCommandInKazBox’
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/cha
    nnel.rb:513:in call' C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/cha nnel.rb:513:indo_open_confirmation’
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/ses
    sion.rb:535:in channel_open_confirmation' C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/ses sion.rb:456:indispatch_incoming_packets’
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/ses
    sion.rb:213:in preprocess' C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/ses sion.rb:197:inprocess’
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/ses
    sion.rb:161:in block in loop' C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/ses sion.rb:161:inloop’
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/connection/ses
    sion.rb:161:in loop' C:/IE_AUTOMATION/kazeon/qa/watir-v1_4-TIP/Lib/KazeonCommon/BasicMethodLibrar y.rb:902:inblock in issueCommandInKazBox’
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh.rb:190:in
    sta rt' C:/IE_AUTOMATION/kazeon/qa/watir-v1_4-TIP/Lib/KazeonCommon/BasicMethodLibrar y.rb:872:inissueCommandInKazBox’
    C:/IE_AUTOMATION/kazeon/qa/watir-v1_4-TIP/KazModules/I18N/I18N_Regression.rb
    :106:in `test_0001’

Thsi is perfectly working with Ruby 1.8.*

After i upgraded ruby to 1.9.2 and this needle, sftp and ssh to new
version, this stops woirking.

I dont even getting any workaround.

thanks
Bhavesh

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs