Ruby on rails 延迟的_作业执行rake未重定向输出

Ruby on rails 延迟的_作业执行rake未重定向输出,ruby-on-rails,ruby,passenger,Ruby On Rails,Ruby,Passenger,我有一个类,目前正在通过延迟作业执行。任务之一是执行“rake spec”并重定向输出 我这样做: class Executor def execute_command(cmd, &block) STDOUT.sync = true # That's all it takes... IO.popen(cmd + " 2>&1") do |pipe| # Redirection is performed using operators pipe

我有一个类,目前正在通过延迟作业执行。任务之一是执行“rake spec”并重定向输出

我这样做:

class Executor
  def execute_command(cmd, &block)
    STDOUT.sync = true # That's all it takes...
    IO.popen(cmd + " 2>&1") do |pipe| # Redirection is performed using operators
      pipe.sync = true
      while str = pipe.gets
      block.call str # This is synchronous!
      end
    end

    return $?.success?
  end
end
但是,没有任何输出出现,它甚至不知道如何正确执行单元测试

Capistrano可以在OSX上工作。我的服务器正在运行

有人知道为什么输出不会被重定向吗

谢谢


Ben

尝试在cmd上不使用STDFDES重定向 这是我用过的和得到的

class Executor
  def execute_command(cmd, &block)
    STDOUT.sync = true # That's all it takes...
    IO.popen(cmd) do |pipe| # Redirection is performed using operators
      pipe.sync = true
      while str = pipe.gets
       block.call str # This is synchronous!
      end
    end

    return $?.success?
  end
end
通过以下方式进行测试:

ex = Executor.new
ex.execute_command "ps aux" do |str|
   p str
end
结果:

“用户PID%CPU%MEM VSZ RSS TT STAT已启动
时间命令\n“mitch 423 3.4 1.0 2750692 159552?? 2012年4月23日19:41.59/Users/mitch/iTerm.app/Contents/MacOS/iTerm -psn_0_40970\n“”_WindowsServer90 3.1 1.8 3395124 301576?Ss 20Apr12 75:19.86 /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/WindowsServer -守护进程\n“mitch 78896 2.0 0.8 1067248 136088??R Thu03PM 37:46.59/Applications/Spotify.app/Contents/MacOS/Spotify -psn_0_4900012\n“mitch 436 1.8 1.0 1063952 169320?S 23Apr12 100:23.87 /Applications/Skype.app/Contents/MacOS/Skype-psn_0_90134\n“