Passing Command Parameters
The command parameters feature allows you to pass information to a command when it is launched by Enteprise Scheduler. You can alter parameters such as dates or other data at runtime, rather than hard-coding the command file itself. You can also use parameters to add flexibility to the same command.
For example, you may have a batch file that can process several files. By specifying its file name as a command parameter, the batch file knows which file to process at any given time.
Enteprise Scheduler uses the standard MS-DOS or command prompt syntax for command parameters. The command parameters are substituted into a command file containing the variable names
%1
,
%2
, etc. Through the DOS prompt, parameters are passed as a list of values separated by spaces after the command. In Enteprise Scheduler, the command parameters are displayed in a list below the command. The first value replaces
%1
, the second value replaces
%2
, and so on, when the batch file is executed.
Tracking Methods
A job’s completion status is determined by its exit code. The exit code can be set by using the
ocsexit
command at the end of a batch file. Using
ocsexit
to facilitate job tracking, the completion status of a job can be:
-
Completed Normally
indicated by an exit code of 0 to notify that the job succeeded
-
Completed Abnormally
indicated by an exit code ≠ 0 to notify that the job ran, but failed.
Note Completion statuses of Skipped, Orphaned, Error Occurred and Externally Defined are also possible but are not determined by the exit code.
The completion status is frequently used to control dependencies. For example, you can set up jobs that run if its predecessor completes with a
Completed Normally
status.
Enteprise Scheduler supports four other tracking methods:
-
External
– You can use this option if you need to inspect the job before determining how the job completed. Enteprise Scheduler sets the status to
Set Externally
when the job completes.
-
Exit Code of cmd pipe
– You can use this option to pipe the output of your job as an input to a command or other output analysis tool. Enteprise Scheduler then uses that command’s exit code as the job’s exit code. You must type the command that invokes the associated tool.
-
Scan Output: Normal String
– Select this option to use a particular text string in the job output to determine if the job completed normally. Enter the exact text that determines “normal” in the text box below.
-
Scan Output: Abnormal String
– Select this option to use a particular text string in the job output to determine if the job completed abnormally. Enter the exact text that determines “abnormal” in the text box below.
The tracking selections are located in the
Tracking
section of the
Run
tab in the
Job Definition
dialog.
Using the Exit Code
In this section, you will create a
Reporting
job group with two jobs,
Report
Writer 1
and
Report Writer 2
.
Each job will use the same command, but will pass a different command parameter. The command parameter is then echoed in the output of both jobs after they complete.
To determine whether the jobs completed successfully or not, both jobs will use the
Exit code of cmd pipe
tracking method using the Windows
Find
command to search for the saved output. The result of the
Find
command will determine the job’s final status.
You will set up
Report Writer 1
to succeed, and
Report Writer 2
to fail. You do this by setting the command parameter for job
Report Writer 1
to
OK
and the parameter for
Report Writer 2
to
FAILED
.
Creating the Reporting Job Group
To create the reporting job group:
Step 1 From the
Navigator
pane, select
Definitions>Jobs
to display the
Jobs
pane.
Step 2 Right-click and select
Add Job Group
from the context menu.
Step 3 In the
Job Group Name
field, enter
Reporting
.
Step 4 Click the
Schedule
tab, if not already selected.
Step 5 From the
Calendar Name
list, select
work day
.
Step 6 Click
OK
to save the job group.
Step 7 Click
Cancel
at the
Effective Date
dialog.
Note If you click OK at this dialog, the job group enters the production schedule, but nothing will run because there are no jobs associated with the job group yet. Clicking Cancel means the job group will be added to the schedule manually.
Setting the Report Writer 1 Job to Succeed
To set the Report Writer 1 job to succeed:
Step 1 Right-click the
Reporting
job group and select
Add>Job
from the context menu.
Step 2 In the
Job Name
field, enter
Report Writer 1
.
Step 3 In the
Command
field, enter the full path to the
Argdemo
batch file.
Step 4 Enter
OK
in the
Command Parameters
field. This passes as
Argument 1 (%1)
to the batch file.
Step 5 Click the
Run
tab.
Step 6 In the
Tracking
section, select the
Exit code of cmd pipe
option.
Step 7 In the text field below, type
grep “OK”
. This tells Enteprise Scheduler to search through the output of the job for the string “OK”. Since “OK” is passed as a command parameter, it will appear in the output.
Step 8 Click
OK
.
Step 9 Click
Cancel
in the
Effective Date
dialog. This job will enter the schedule when manually submit its job group.
Setting the Report Writer 2 Job to Fail
To set the Report Writer 2 job to fail:
Step 1 Right-click the
Report Writer 1
job in the jobs view.
Step 2 Select
Copy Job/Group
from the context menu.
Step 3 Double-click the
Copy of Report Writer 1
job to open its definition for editing.
Step 4 In the
Job Name
field, change
Copy of Report Writer 1
to
Report Writer 2
.
Step 5 In the
Command Parameters
field, change
OK
to
FAILED
.
The
Run
tab should contain
grep “OK”
in the
Tracking
section. This was inherited when you copied the job.
Step 6 Click
OK
.
Step 7 Click
Cancel
at the
Effective Date
dialog.
Adding the Reporting Job Group to the Production Schedule
To add the Reporting job group to the production schedule:
Step 1 Right-click the
Reporting
job group.
Step 2 Select
Insert Job into Schedule
from the context menu.
Step 3 Click
OK
in the
Insert Job Into Schedule
dialog.
Step 4 Click
OK
in the
Information
dialog.
The jobs start with one completing normally and the other completing abnormally. The job group results in a
Completed Abnormally
status because one of its jobs completed abnormally.
Setting Report Writer 2 to Complete Normally
To set Report Writer 2 to Complete Normally:
Step 1 In the
Job Definition
dialog, double-click the
Report Writer 2
job.
Step 2 In the
Job Definition
dialog, change the
Command Parameter
value from
FAILED
to
OK
.
Step 3 Click
OK
.
Step 4 Click
OK
at the
Effective Date
dialog.
Step 5 Re-submit the jobs by adding the
Reporting
job group using the
Insert into Schedule
option, from the right-click context menu or selecting the option from the
Actions
main menu.
Step 6 Click
OK
when the
Insert Job Into Schedule
dialog displays.
Step 7 Click
OK
in the
Information
dialog.
Both
Report Writer 1
and
Report Writer 2
complete successfully.