From: Shay Hawkins Date: 2010-01-05T01:41:48+09:00 Subject: Re: "Dummy" IO object to push and pull data? Test program: # Required support, go to process dir require("open3.so") Dir.chdir("..") # Initiate the process and its streams command = "********" inline, outline, errline = Open3.popen3(command) # Quick function for short timestamps require("time") def tstamp(line) puts("#{Time.now().to_s().split(" ")[3]} #{line}") end # Read from stderr, thread stdin input loop do tstamp("> Awaiting data...") line = errline.gets().strip() tstamp("Output: #{line}") if(line == "0") tstamp("> Received the required line.") Thread.new() do tstamp("> The thread has been created.") sleep(5) tstamp("> Time's up! Sending input...") inline.puts("EXIT") tstamp("> The input has been sent.") end end end Output: 11:35:03 > Awaiting data... 11:35:03 Output: 2 11:35:03 > Awaiting data... 11:35:13 Output: 3 11:35:13 > Awaiting data... 11:35:23 Output: 0 11:35:23 > Received the required line. 11:35:23 > The thread has been created. 11:35:23 > Awaiting data... 11:35:33 Output: 4 11:35:33 > Awaiting data... 11:35:43 Output: 1 11:35:43 > Awaiting data... -- Posted via http://www.ruby-forum.com/.