From: Eirikur Hallgrimsson Date: 2002-01-16T04:30:40+09:00 Subject: Naive thread question. This is just killing me. I need to do a bunch of shell commands in parallel. I want to get the output if there is any. I have tried Thread.New, but contrary to the docs, I can't seem to use an instance variable to pass data out of the thread. Globals work. I want my node object to have access to this command output, but in order to execute in parallel I have to use threads or fork. I have tried passing instance and local variables into the thread explicitly ala Thread.new(@myvar) or Thread.new(myvar). def command ( the_command ) t = Thread.new do sin, sout, serr = Open3.popen3( the_command ) sout.each_line { |line| puts line } # prints output to stdout @instanceVar = sout.readlines # get output into array sout.close end # of Thread print @instanceVar # instanceVar is unchanged. end # def command