How to create a continuous process with some cmd calls using ruby rake in Windows?

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|

    $cmd<<("set MYVAR=#{value}")
    $cmd<<("set MYVAR")
  rescue Exception => e
    puts e.message

task :CmdTest3 do

  IO.popen("cmd", "r+") do |io|
    th = do |chan|
      chan.each {|line| puts line}
    $cmd.each do |f|
      io.puts f


Posted via