From: "Sandor Szücs" Date: 2008-07-22T04:24:38+09:00 Subject: Re: How to invoke an external program and get anything the pgm returns back On 21.07.2008, at 20:35, Victor Reyes wrote: > 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 Ask $? to get the information. $?.exitstatus > But *rc* does not have anything of value. It has either *true* or > *false*. irb> res = `ls file_not_exists` ls: file_not_exists: No such file or directory => "" irb> $?.exitstatus => 1 According to ri page Kernel.system also sets $? $ qri Kernel.system ---------------------------------------------------------- Kernel#system 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. hth. regards, Sandor Szücs --