On 15/08/05, LenS <lsumnler / uniqueinsuranceco.com> wrote:
> I am running Ruby 1.8.2 on a XP machine.  I have several programs
> (executables) which convert text files to a special file format.  I
> would like to have these programs run from within a ruby script and
> check the return code.
> 
> In general how would you call the foo.exe program in ruby and check
> return code.
> 
> Thanks
> Len Sumnler
> 
> 

def execute(*args)
  system(*args)
  $?
end

execute("echo 'test' | grep -q test")    # => #<Process::Status:
pid=21948,exited(0)>
execute("echo 'nothing' | grep -q test") # => #<Process::Status:
pid=21951,exited(1)>

Read ri Process::Status for more information on the Process::Status Class.

regards,

Brian

-- 
http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/