How to return exit code in UniData?

104 Views Asked by At

Is there a way to return an exit code to the operating system in UniBasic or ECL ?

For example I want to capture a user-programmable exit code that can be retrieved with Bash's $? variable.

From what I see, the UniBasic STOP and ABORT commands only return execution to the UniData system level (eg. udt) (rather than exit to shell).

I am using Rocket UniData version 7.3.7.

1

There are 1 best solutions below

0
On

I don't know of any direct way to set the exit code of udt, but two alternative approaches :

  1. Have the program explicitly write to a known location, and then have the bash script check that file for let's say "ERROR" using grep.

  2. Have the program print some kind of output to screen (e.g. PRINT "OK" if all went well, or PRINT "ERROR" if there was an error), and pipe the output of the command through grep, e.g.

$udt RUN.MY.PROGRAM | grep "OK"
$echo $?
1

And then the exit code from grep can be used to tell if the command succeeded or not (depending on what you search for, it might be backwards - e.g. a zero means OK was found, but a 1 means it was not found).