From: James Dinkel Date: 2008-09-11T15:37:33+09:00 Subject: Re: How to execute files or commands in ruby? I use popen3 because I usually want to capture any output to stderr as well as stdout. Here is an example: Open3.popen3("commandname") do |input_stream, output_stream, error_stream| standard_output = output_stream.read standard_error = error_stream.read end The variables "standard_output" and "standard_error" will be string variables at that point, containing the text of the error and output streams. I haven't had a need to use stdin, but I suspect calling the 'write' method on "input_stream" would be be the equivalent of piping information to the command. However, it may also provide a method of scripting an interactive command. You can also use it without a block like this: [input_stream, output_stream, error_stream] = Open3.popen3("commandname") You then have an array containing the IO streams, and then you could call the 'read' method on the streams just as above, although I've always used the block form. James -- Posted via http://www.ruby-forum.com/.