The Argent Job Scheduler supports three important constructs that can be combined to provide great flexibility to customer-developed applications.
Environment string support provides a way for a customer to set the value of an environment variable that will be accessible to customer jobs during execution. Environment strings are defined for a job using the Advanced Settings display (Screen ID J20E).
A customer application, for example, could use an environment string to indicate an application version. This is shown below:
Environment strings can be read by a customer application using batch command file syntax (“%VARIABLE_NAME%“) or by calling Windows APIs.
The Argent Job Scheduler supports several expressions known as substitution variables. They are:
|%ServerNode%||– Name of node where job executes|
|%JOB_FILE%||– Job command file name|
|%JOB_NAME%||– Job name|
|%JOB_NUMBER%||– Job number assigned by Queue Engine|
|%LOG_FILE%||– Log file name|
|%QUEUE%||– Queue name assigned by Queue Engine|
|%EXIT_CODE_FILE%||– Exit Code file name|
|%JOB_STATUS%||– Job status|
Substitution variables can be used in job parameters, environment strings, and alert text.
Please note that the job number and queue name are assigned by the Argent Queue Engine after the job has started executing and are not available until the job has started.
A job that has %JOB_NUMBER% defined in an alert text that is sent when the job fails to start will not have the expected results since, by definition, the job number is not available until the job has started executing.
A job that has a list of queues or a queue macro expressed within the job definition should not use the %QUEUE% substitution variable until the job has started because the value of the queue name is not resolved until the job is ready to start.
Global Text String Macros
Global text string macros can be defined using the J48 display. Global text string macros can be used in job parameters, environment strings, and alert text. A global text string can be defined, for example, that expresses the current date. The global text string macro can then be used as a job parameter to pass the current date to the job.
The most common way to feed an environment variable to Jobs is through the Job Basic (J20A) screen, where you would probably provide a set variable (such as the date, time, or a particular server you want a file to run on — as in the case of a scheduled virus scan).
However, there are times in which you will need to provide many different variables to the Job in question, and this is where Global String Macros are handy.
Example A: Using Job Basic (J20A) Screen
In this example, we are running a simple command file called JOB1.CMD. you can see on the parameter line, we have provided %TX_DIRECTORYNAME% as our command line switch.
For the purpose of this example, the following is what JOB1.CMD might look like:
REM sample batch file demonstrating environment variables @echo off dir %1 dir %2 dir %3 exit
Normally, if we were running this batch file from the DOS prompt, we would have to supply the environment variables %1 through %3 each time we ran the file. Not so when using the Argent Job Scheduler combined with a Global String Macro.
Example B: Using Global String Macro
Look at the example of what our Global String Macro (&TX_DIRECTORY) might look like.
Viewing the macro definition, we can see that there are 3 values presented as part of this macro.
You can see that our Global String Macro, which we can easily edit on the fly at any time, will run a directory of the 3 locations listed in the macro (%1 through %3).
In another example, let’s say we have a variable called %ARB on our system, and that variable’s value is D:\Archives.
You can actually try this on your workstation by using the
SET command in DOS.
We could substitute one of the values in the Global String Macro (&TX_DIRECTORY) with the variable %ARB and this will function just as well.
You cannot input this variable in the Global String Macro in the format of %VARIABLE%. The “%” must not be present at the end of the variable. This will cause the macro to fail.