Project

General

Profile

Getting result of command in return code

Added by Jan Elbers over 11 years ago

Hi,

Is it possible to get the result (success or fail) of a CDO command returned to a (logic) variable ?, so for example

result = cdo mergetime ....
if (result) then ...
...

It would be helpful for long scripts with many cdo commands to know if it goes wrong somewhere.

Cheers,
Jan


Replies (1)

RE: Getting result of command in return code - Added by Ralf Mueller over 11 years ago

In Any kind of standard shell, you have the return values @$?$ of the last command, which is 0 in case of success and 1 otherwise. In Python and Ruby, an exception is raised.

In shell a small wrapper around CDO, which checks $? after each call and exits in case of value non-zero might do the job.

    (1-1/1)