From: Rajeswar reddy Gaulla Date: 2009-06-19T16:34:09+09:00 Subject: Issue with multi threading 1 require 'net/ssh' 2 Net::SSH.start('10.10.2.3', 'test', :password => "test123") do |ssh| 3 productsList=['test1', 'test2', 'test3', 'test4', 'test5'] 4 puts Time.now 5 threads = [] 6 for product in productsList 7 threads << Thread.new(product) { |product1| 8 baseDir='$HOME/Repository/' 9 fileslist= [] 10 confFolders=['conf', 'bin'] 11 confFolders.each{|confFolder| 12 13 stdout = "" 14 fileslist_temp=[] 15 16 puts "path: ls -1 #{baseDir}/#{product1}/#{confFolder}/" 17 ssh.exec!("ls -1 #{baseDir}/#{product1}/#{confFolder}/") do |channel, stream, data| 18 stdout<< data if stream == :stdout 19 end 20 fileslist_temp=stdout.split("\n") 21 fileslist_temp.each{|file| 22 file.strip! 23 temp="#{confFolder}/"+file 24 fileslist.push(temp) 25 } 26 } 27 config_files_list=fileslist.join(", ") 28 puts "#{product1} Proudct List: #{config_files_list}" 39 } 30 end 31 threads.each { |aThread| aThread.join } 32 puts Time.now 33 end Above program is giving below exception, please help me to fix this issue. C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:200:in `select': An operation was attempted on something that is not a socket. (Errno::ENOTSOCK) from C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:200:in `process' from C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:160:in `block in loop' from C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:160:in `loop' from C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:160:in `loop' from C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/channel.rb:269:in `wait' from C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:354:in `exec!' from Thread.rb:17:in `block (4 levels) in
' from Thread.rb:12:in `each' from Thread.rb:12:in `block (3 levels) in
' 2009-06-19 11:28:43 +0530 path: ls -1 $HOME/Repository//test1/conf/ path: ls -1 $HOME/Repository//test2/conf/ path: ls -1 $HOME/Repository//test3/conf/ path: ls -1 $HOME/Repository//test4/conf/ path: ls -1 $HOME/Repository//test5/conf/ Attachments: http://www.ruby-forum.com/attachment/3832/Thread.rb -- Posted via http://www.ruby-forum.com/.