From: otaku Date: 2004-09-12T00:54:59+09:00 Subject: Re: Net-SSH Threaded PortForward Script Problems jamis, i reversed order and still no luck i get the following error message from the below code irb is telling me that the thread is still being killed prior to anything starting: BEGIN ERROR MESSAGE ---------- [root@falcon1 src]# ./example.rb /usr/local/lib/ruby/site_ruby/1.8/net/ssh/transport/session.rb:132:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED) from /usr/local/lib/ruby/site_ruby/1.8/net/ssh/transport/session.rb:132:in `open' from /usr/local/lib/ruby/site_ruby/1.8/net/ssh/transport/session.rb:132:in `initialize' from /usr/local/lib/ruby/site_ruby/1.8/net/ssh.rb:175:in `new' from /usr/local/lib/ruby/site_ruby/1.8/net/ssh.rb:175:in `open' from /usr/local/lib/ruby/site_ruby/1.8/net/ssh.rb:93:in `start' from ./example.rb:19 --------- END ERROR MESSAGE BEGIN CODE ------------- #!/usr/local/bin/ruby require 'thread' require 'net/ssh' require 'net/ssh/service/forward' threads = [] t = Thread.new do Net::SSH.start( 'localhost', 'localuser', 'passwd' ) do |session| mgr = PortForwardManager.new( session ) mgr.forward_local( 1236, '10.0.0.4', 22 ) session.main_loop end end Net::SSH.start( 'localhost', 1236, 'remoteuser', 'passwd' ) do |session| result = session.exec("hostname; uptime") puts result.data end threads.push( t ) threads.each { |t| t.join } ------ END