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.
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.
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 $?
Executes cmd in a subshell, returning true if the command was
found and ran successfully, false otherwise. An error status is
available in $?. The arguments are processed in the same way as
for Kernel::exec.
On Mon, Jul 21, 2008 at 3:24 PM, Sandor Szücs [email protected]
wrote:
KSH:
irb> res = ls file_not_exists
system(cmd [, arg, …]) => true or false
Executes cmd in a subshell, returning true if the command was
found and ran successfully, false otherwise. An error status is
available in $?. The arguments are processed in the same way as
for Kernel::exec.