I’m trying to run some windows command line calls in the same system
process using a Ruby Rake task. I need to find the way to do the calls
correctly and this calls can’t be dependent on each other.
I know that the ‘fork’ function can be a solution, but it doesn’t work
in Windows. I tried with other functions, like IO.POPEN and
Process.spawn and I didn’t find a real solution.
I’m working with Ruby 1.9.3 in windows XP.
task :CmdTest,:value do |t, args|
value=args.value.to_s
begin
$cmd<<("set MYVAR=#{value}")
$cmd<<("set MYVAR")
$cmd<<("exit")
rescue Exception => e
puts e.message
end
end
task :CmdTest3 do
IO.popen(“cmd”, “r+”) do |io|
th = Thread.new(io) do |chan|
chan.each {|line| puts line}
end
$cmd.each do |f|
io.puts f
end
io.close_write
th.join
end
end