If you use a series of commands frequently or you must enter many commands to complete a task, consider automating the task with a script or batch file. These files are useful for batch data loads and complex calculations.
Note: On UNIX, a batch or script file is written as a shell script. A shell script usually has the file extension .sh (Bourne or Korn shell) or .csh (C shell).
When you run a script or batch file, ESSCMD executes the commands in order until it reaches the end of the file.
Existing script or batch files might be affected by changes to some commands. To ensure that your files work in Hyperion Essbase Release 6, check on your use of changed or deleted commands. See the Start Here booklet for information about new and changed commands.
ESSCMD script files automate an often-used or lengthy series of commands. Each script file must be a complete ESSCMD session, with login, application and database selection, logout, and termination commands.
To define a script file:
.SCR
ESSCMD script file extension.
For example, the following script file, TEST.SCR
, was created in Notepad:
LOGIN "LOCAL" "TOMT" "PASSWORD"; SELECT "SAMPLE" "BASIC"; GETDBSTATE EXIT; |
When run from the operating system command line, this script logs TomT into the Hyperion Essbase Local server, selects the Sample application and Basic database, gets database statistics, and quits the ESSCMD session.
Enter the following command at the operating system prompt:
ESSCMD scriptFileName.SCR
Replace scriptFileName with the name of the script file. For example, type the following if the script file is in the current directory:
ESSCMD TEST.SCRIf the script file is in another directory, include the path. For example:
ESSCMD C:\WORK\SCRIPTS\TEST.SCR
(an absolute path on Windows NT)
or
ESSCMD ..\SCRIPTS\TEST.SCR
(a relative path on Windows NT)
In this LOAD.SCR
example file, if a command does not execute successfully, ESSCMD branches to the end of the file to avoid completing other operations.
LOGIN "local" "User1" "password" "Sample" "Basic"; LOADDATA 2 "calcdat"; IFERROR "Error"; CALC "Calc All;"; IFERROR "Error"; RUNREPT 2 "Myreport"; IFERROR "Error"; [possible other commands] EXIT; :Error EXIT; |
Note: You can use the OUTPUT command to log errors to a text file.
The following script files demonstrate common Hyperion Essbase batch operations. All samples are based on the Sample Basic database that comes with Hyperion Essbase. The scripts for these examples are available in your \ESSBASE\APP\SAMPLE\BASIC directory. On UNIX systems, the examples are available from /home/essbase/app/Sample/Basic.
Suppose you need a file that executes the following actions:
The following script file does the job:
LOGIN "Poplar" "TomT" "Password"; SELECT "Sample" "Basic"; DISABLELOGIN; IMPORT 2 "ACTUALS" 4 "Y" 2 "ACTUAL" "N"; CALCDEFAULT; ENABLELOGIN; EXIT; |
On Windows NT, this script file, SAMPLE1.SCR, is available in your \ESSBASE\APP\SAMPLE\BASIC directory. On UNIX platforms, SAMPLE1.SCR is in your /essbase/app/Sample/Basic directory.
Suppose you need a script file that executes the following actions:
The following script file does the job:
LOGIN "Poplar" "TomT" "Password"; SELECT "Sample" "Basic"; DISABLELOGIN; BUILDDIM 2 "PRODRUL" 4 "PRODTBL" 4 " PROD.ERR " ; IMPORT 4 "TOMT" "PASSWORD" 2 "ACTUAL" "N"; CALCDEFAULT; EXIT; |
On Windows NT, this script file, SAMPLE2.SCR, is available in your \ESSBASE\APP\SAMPLE\BASIC directory. On UNIX systems, SAMPLE2.SCR is in your /essbase/app/Sample/Basic directory.
You can write a batch file that runs one or more report scripts, and includes operating system commands. See your operating system instructions to learn the syntax for writing batch files.
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. For information about handling errors in script files, see Handling Command Errors in a Script File.
For example, a batch file could contain three scripts: an ESSCMD batch file that loads data, a calc 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 going on. 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 an NT 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%==goto Error ESSCMD CALC.SCR If not %errorlevel%==goto Error ESSCMD REPORT.SCR If not %errorlevel%==goto Error Echo All operations completed successfully EXIT :Error Echo There was a problem running the script |
Suppose you need a file that executes the following actions:
The following script file does the job:
LOGIN "Poplar" "TomT" "Password"; SELECT "Sample" "Basic"; RUNREPT 2 "REP1" "REP1.OUT"; RUNREPT 2 "REP2" "REP2.OUT"; RUNREPT 2 "REP3" "REP3.OUT"; EXIT; |
On Windows NT, this script file, SAMPLE3.SCR, is available in your \ESSBASE\APP\SAMPLE\BASIC directory. On UNIX platforms, SAMPLE3.SCR is in your /essbase/app/Sample/Basic directory.
Copyright (c)1991-2000 Hyperion Solutions Corporation. All rights reserved.