Various monitoring applications require the exit code/status of a process as an input.
A simple example (test1.sh):
Let’s run it:
Let’s check the exit status (of the last command) which can be accessed via $?:
$ echo $?
Let’s take a look at how we can get the exit status from Pan and Kitchen:
For demonstration purposes we create a very simple dummy transformation which just outputs some data to the log:
Now create a shell file:
/opt/pentaho/pdi/pdi-ce-4.4.0-stable/pan.sh -file='/home/dsteiner/Dropbox/pentaho/Examples/PDI/exit_code/tr_dummy.ktr' -Level=Basic > /home/dsteiner/Dropbox/pentaho/Examples/PDI/exit_code/err.log
Note the echo $? in the last line which will return the exit status. This is for demonstration purposes here only. Normally you would use exit $? instead.
On Windows use instead:
Now lets run the shell script:
The exit status tells us that the transformation was executed successfully.
Next we will introduce an error into the transformation. I just add a formula step with a wrong formula:
We run the shell script again and this time we get a return code other than 0:
Any return code other than 0 means it is an error.
The job ran without a problem
Errors occurred during processing
An unexpected error occurred during loading / running of the job / transformation, an error in the XML format, reading the file, problems with the repository connection, ...
unable to connect to a database, open a file or other initialization error.
The job / transformation couldn't be loaded from XML or the Repository
Error loading job entries or steps or plugins (error in loading one of the plugins mostly).one of the plugins in the plugins/ folder is not written correctly or is incompatible. You should never see this anymore though. If you do it's going to be an installation problem with Kettle.
Command line usage printing