Hi,
I have routines to send commands to remote computer.
def issueCommandInKazBox5(okMachine="", command="", matchLog="",
user="admin", passwd="kazeon")
puts " issueCommandInKazMachine=#{okMachine}"
puts " issueCommandInKazcommand=#{command}"
puts " issueCommandInKazstatus=#{matchLog}"
puts " issueCommandInKazuser=#{user}"
puts " issueCommandInKazpasswd=#{passwd}"
Net::SSH.start(okMachine, user, :password => "kazeon", :auth_methods
=> ["password"]) do |session|
session.open_channel do |channel|
channel.request_pty do |ch, success|
raise "Error requesting pty" unless success
ch.send_channel_request("shell") do |ch, success|
raise "Error opening shell" unless success
end
end
channel.on_data do |ch, data|
STDOUT.print data
end
channel.on_extended_data do |ch, type, data|
STDOUT.print "Error: #{data}\n"
end
channel.send_data "#{command}\n".force_encoding('utf-8')
channel.send_data "exit\n"
session.loop
end
end
end
I fire commands like this to get the command fire on remote machine :
issueCommandInKazBox($node1, "add user bhavesh role admin", "")
It works properly for english data.
But when i have utf8 data, it throws error :
issueCommandInKazBox($node1, "add user âêžýáíúöóá¿ role admin", "")
Error is :
1) Error:
test_0001(TC_I18N):
OpenSSL::Cipher::CipherError: data not multiple of block length
C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/
transport/stat
e.rb:85:in `final'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/
transport/stat
e.rb:85:in `final_cipher'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/
transport/pack
et_stream.rb:142:in `enqueue_packet'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/
transport/sess
ion.rb:223:in `enqueue_message'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/
connection/ses
sion.rb:368:in `send_message'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/
connection/cha
nnel.rb:493:in `enqueue_pending_output'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/
connection/cha
nnel.rb:312:in `process'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/
connection/ses
sion.rb:214:in `block in preprocess'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/
connection/ses
sion.rb:214:in `each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/
connection/ses
sion.rb:214:in `preprocess'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/
connection/ses
sion.rb:197:in `process'
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:in `loop'
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:2523:in `block (2 levels) in issueCommandInKazBox5'
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:in `do_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:in `dispatch_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:in `process'
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:in `loop'
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:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh/
connection/ses
sion.rb:110:in `close'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/net-ssh-2.1.4/lib/net/ssh.rb:
191:in
`sta
rt'
C:/IE_AUTOMATION/kazeon/qa/watir-v1_4-TIP/Lib/KazeonCommon/
BasicMethodLibrar
y.rb:2500:in `issueCommandInKazBox5'
C:/IE_AUTOMATION/kazeon/qa/watir-v1_4-TIP/KazModules/I18N/
I18N_Regression.rb
:71:in `test_0001'
I already have encoding set to utf8 in my script.
what do i have to change to get it working? and where?
Bhavesh
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]