Ruby's standard popen3 module does not work on Windows. Is there a maintained replacement that allows for separating stdin, stdout, and stderr?
views:
271answers:
2
+3
A:
POpen4 has a common interface between unix and Windows. The following example (from their website) works like a charm.
require 'rubygems'
require 'popen4'
status =
POpen4::popen4("cmd") do |stdout, stderr, stdin, pid|
stdin.puts "echo hello world!"
stdin.puts "echo ERROR! 1>&2"
stdin.puts "exit"
stdin.close
puts "pid : #{ pid }"
puts "stdout : #{ stdout.read.strip }"
puts "stderr : #{ stderr.read.strip }"
end
puts "status : #{ status.inspect }"
puts "exitstatus : #{ status.exitstatus }"
Max Caceres
2008-09-23 16:43:56