SMS makes a heavy use of different kind of variables. It is not easy task to understand how they all link together, but let's try:
There are three kinds of variables and sometimes it may be confusing to know which variable is doing what, and especially which kind of variable they are. There are environment variables which are set in UNIX shell before the SMS-programs start. Then there are internal variables. There is two kinds of internal variables. The shell, or IOI-variables, and suite definition variables. And to add to the confusion SMS even generates variables. (So if you count them, the correct number is four ;-)
Following sections list the generated and user defined variables which have special meaning for SMS itself.
In a SMS script, variables are written as text enclosed by a pair of %-characters (the edit-character.) As in C-format strings, if there are two %-characters together they are concatenated to form a single %-character in the job-file.
For example if you need to execute UNIX command
date +%d
in a job, you must enter it as
date +%%d
into the sms-file.
At present, the edit-character can only be defined when SMS is compiled. In SMS V4.3 it is possible to configure the edit-character to be defined as a variable SMSMICRO. The default installation uses %-character only.
User defines variables in a suite definition file using the edit(play) command. User defined variables can occur at any node level: suite, family or task. SMS also generates variables from the node name, the host on which SMS is running, the time, the date and so on.
When a variable is needed at submission time, it is first sought in the task itself. If it is not found in the task, it is sought from the task's parent and so on, up through the node levels until found. For any node, there are two places to look for variables. The user-defined variables are looked for first, and then any generated variables.
At present, an undefined variable causes a task to abort immediately, without submitting a job. SMS version 3 used to issue a warning message and replace the undefined variable by a null string. For safety this is not the case with SMS V4.x.
XCdp will display this failure in the info-window.
Variable inheritance
suite x
edit TOPLEVEL 10
edit MIDDLE 10
edit LOWER 10
family f
edit MIDDLE 20
task t
edit LOWER abc
task t2
endfamily
family f2
edit TOPLEVEL 40
task z
endfamily
Following extract from a sms-file using the above suite definition
echo TOPLEVEL %TOPLEVEL% echo MIDDLE %MIDDLE% echo LOWER %LOWER%
would produce:
| Command | task t | task t2 | task z |
|---|---|---|---|
| echo TOPLEVEL %TOPLEVEL% | 10 | 10 | 40 |
| echo MIDDLE %MIDDLE% | 20 | 20 | 10 |
| echo LOWER %LOWER% | abc | 10 | 10 |