From: Damphyr Date: 2005-11-25T17:23:53+09:00 Subject: Re: system() on windows snacktime wrote: > On 11/24/05, Damphyr wrote: > > >>Try cmd=ExecCmd.new("rake");puts cmd.success?;puts cmd.output using the >>class at the end of this message (Ara's solution for grabbing the output >> of stderr and stdout on windows with a broken popen3 was better - >>giving you separate stderr und stdout - but this one has benchmarking >>too :) ). > > > In initialize block_given? is returning false for me. Any idea why? > Did you pass a block? Actually I missed cmd.run in there (what do you expect at quarter to two?). You can do it like this: ExecCmd.new("rake"){|cmd| puts cmd.success? puts cmd.output } or like this: cmd=ExecCmd.new("rake") cmd.run puts cmd.success? puts cmd.output But a nice sideeffect of this implementation was cmd1=ExecCmd.new("blabla") cmd2=ExecCmd.new("blabla2") cmd3=ExecCmd.new("blabla3") [cmd1,cmd2,cmd3].each{|cmd| cmd.run #do stuff with it } And afterwards you also have a crude benchmark for each command i.e. :) [cmd1,cmd2,cmd3]each{|cmd| if cmd.run? status="succeeded" status="failed" unless cmd.success? puts "#{cmd.cmd} #{status} in #{cmd.exec_time}s" puts "Log:\n#{cmd.output}" unless cmd.success? else puts "#{cmd.cmd} was not executed" end } -- http://www.braveworld.net/riva ____________________________________________________________________ http://www.freemail.gr - ������ �������� ������������ ������������. http://www.freemail.gr - free email service for the Greek-speaking.