From: Jim Menard Date: 2008-07-22T04:13:26+09:00 Subject: Re: How to invoke an external program and get anything the pgm returns back On Mon, Jul 21, 2008 at 2:35 PM, Victor Reyes wrote: > Team, > > I have a Ruby script which might invoke an external program. > The external program could be written in: Ruby, Perl, KSH, CSH, BSH, Etc. > The invoked program might return a value in the the form of a return code. > For example, a KSH script might execute an *exit 99* stmt and which value I > would like to capture in the invoker, Ruby script. The global variable $? holds the exit status. If you require 'English' then you can use the name $CHILD_STATUS instead of $? > > I tried: > Ruby script segment: > rc = `/usr/local/bin/script_name` > > I also tried in the Ruby caller script: > system("/usr/local/bin/script_name") > > > > KSH: > exit 99 > > But *rc* does not have anything of value. It has either *true* or *false*. > ======================== > > Also, using Ruby to Ruby I still can't get a Ruby script called another Ruby > script, have the called script returns a value and have the invoker Ruby > script get the value. > > Is there anyway to get what I described above? > > Thank you > > Victor > Jim -- Jim Menard, jimm@io.com, jim.menard@gmail.com http://www.io.com/~jimm/