Cheers, everyone
I need to run a potentially lengthy process from Ruby 1.9.2 on Windows, and then capture and parse data from an external output process and errors. A large amount of data can be sent for each, but I am only interested in one line at a time (without capturing and not saving all the output).
After a little research, I found that the Open3 class will take care of executing this process and giving me IO objects related to the standard output and the process error (via popen3 ).
Open3.popen3("external-program.bat") do |stdin, out, err, thread| # Step3.profit() ? end
However, I'm not sure how to constantly read from both threads without blocking the program. Since calling IO#readlines on out or err when a lot of data has been sent results in a memory allocation error, I try to constantly check both threads for accessible input, but not having much luck with any of my implementations.
Thanks in advance for any advice!
source share