S
S Kanakakorn
I have this simple code.
require 'rubygems'
require 'net/ssh'
begin
session = Net::SSH.start('aaaa-lnx',
assword=>'xyz',
:username=>'root',:timeout=>5)
rescue
puts 'cannot connect '
ensure
puts 'reach ensure point'
end
puts 'at last'
--------------------------------------
If I put in non existing host name (aaaa-lnx), then the statement
"puts 'at last'" won't print out.
The ensure blocks work fine. Somehow, the "rescue" block can't catch
the error. This is my output.
reach ensure point
/Applications/Locomotive2/Bundles/standardRailsJan2007.locobundle/i386/lib/ruby/1.8/timeout.rb:54:in
`open': execution expired (Timeout::Error)
from /Applications/Locomotive2/Bundles/standardRailsJan2007.locobundle/i386/lib/ruby/gems/1.8/gems/net-ssh-1.0.10/lib/net/ssh/transport/session.rb:88:in
`initialize'
If I put in a good hostname with wrong password, the "rescue" block
will catch the error just fine. Here is the output:
cannot connect
reach ensure point
at last
What did I do wrong ?
Thanks,
-Nick
require 'rubygems'
require 'net/ssh'
begin
session = Net::SSH.start('aaaa-lnx',
:username=>'root',:timeout=>5)
rescue
puts 'cannot connect '
ensure
puts 'reach ensure point'
end
puts 'at last'
--------------------------------------
If I put in non existing host name (aaaa-lnx), then the statement
"puts 'at last'" won't print out.
The ensure blocks work fine. Somehow, the "rescue" block can't catch
the error. This is my output.
reach ensure point
/Applications/Locomotive2/Bundles/standardRailsJan2007.locobundle/i386/lib/ruby/1.8/timeout.rb:54:in
`open': execution expired (Timeout::Error)
from /Applications/Locomotive2/Bundles/standardRailsJan2007.locobundle/i386/lib/ruby/gems/1.8/gems/net-ssh-1.0.10/lib/net/ssh/transport/session.rb:88:in
`initialize'
If I put in a good hostname with wrong password, the "rescue" block
will catch the error just fine. Here is the output:
cannot connect
reach ensure point
at last
What did I do wrong ?
Thanks,
-Nick