我想運行一個正在生成一些文件的腳本,並且希望每3分鐘檢查腳本生成的文件的存在。如何運行一個程序並在運行程序時定期檢查輸出是否存在
我做了以下內容,
def periodic_method time, block
t = EventMachine::PeriodicTimer.new(time) {eval(block)}
begin
yield
ensure
t.cancel
end
end
periodic_method(60, "if File.exists(file1.txt) then puts 'done with step 1' else puts 'running generator'") do
generator.rb
end
運行時我得到錯誤錯的沒有參數。
這裏是堆棧跟蹤: -
wrong number of arguments (1 for 0)
/tools/simulation/simulation_assemble/test.rb:652:in `eval'
(eval):1:in `block in periodic_block'
/tools/simulation/simulation_assemble/test.rb:652:in `eval'
/tools/simulation/simulation_assemble/test.rb:652:in `block in periodic_block'
/tool/pandora64/.package/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4
/lib/em/timers.rb:52:in `call'
/tool/pandora64/.package/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4/lib/em/timers.rb:52:in `fire'
/tool/pandora64/.package/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:206:in `call'
/tool/pandora64/.package/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:206:in `run_machine'
/tool/pandora64/.package/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:206:in `run'
generator.rb:195:in `block in run'
generator.rb:168:in `standard_exception_handling'
generator:191:in `run'
generator:28:in `< main>'
在實現我的任務任何人的幫助?
有沒有其他的方式來完成這項任務?
請先格式化你的代碼! – fengd
你到底在做什麼錯誤? –
我得到這個錯誤「錯誤的參數數量(1爲0)」 – anamika