For the operating system batch file, you can use ESSCMD command return values to control the flow of scripts that the batch file executes.
An ESSCMD program returns an integer value upon exiting. This value represents the status of the last executed command, usually whether the command succeeded or failed. You can set up your batch file to test for this value, and if the test fails, branch to an error-handling response. This process is similar to creating a script file. See Handling Command Errors in Script Files.
For example, a batch file could contain three scripts: an ESSCMD batch file that loads data, a calculation script that performs calculations on the data, and a report script that reports on the results of the calculation. If the load batch file fails, the calculations and reporting also fail. In this case, it would be best to stop the batch file after the failure of the load file and correct the error that caused the failure before continuing. If your batch file tests for the return value of the load process, and this return value indicates failure, the batch file can jump to the end of the file and stop or execute some other error-handling procedure, rather than attempting to calculate data that did not load.
The following example shows a Windows operating system batch file and the contents of one of the ESSCMD scripts it runs, load.scr. Because error-checking requirements vary, the syntax in this example may not correspond to that of your operating system. See your operating system documentation for error checking in batch files.
An operating system batch file could contain commands like this:
ESSCMD LOAD.SCR If not %errorlevel%==0 goto Error ESSCMD CALC.SCR If not %errorlevel%==0 goto Error ESSCMD REPORT.SCR If not %errorlevel%==0 goto Error Echo All operations completed successfully EXIT :Error Echo There was a problem running the script