HP StorageWorks Storage Mirroring for Linux Scripting Guide (T2558-96319, June 2009)

2 - 2
Storage Mirroring scripts
You can create script files to execute series and combinations of Storage Mirroring commands to meet
specific needs. When working with scripts, keep in mind the following.
When creating Storage Mirroring scripts, each commented line must start and end with the pound
(or number) sign (#).
Storage Mirroring scripts must use ANSI coding. Do not use Unicode or other formats.
Variables can be used in commands to replace items that vary such as machine or domain names.
A variable name must start with the dollar sign ($) character and can contain letters, numbers,
strings, and integers. Values are assigned to variables using the equals (=) assignment
statement. For example, valid variable assignment statements are $MyDomain="domain.com";
and $MySource=alpha;.
All Storage Mirroring commands return values which can also be assigned to variables. For
example, the connection command returns a connection ID for the connection being created. The
statement $ConnectionID=CONNECT dataset to target; saves the connection ID as a variable.
The variable components of the connect command could be replaced as well. For example,
$TheRepset="DataFiles";, $TheTarget=beta;, and $ConnectionID=CONNECT $TheRepset to
$TheTarget; are all valid statements.
Storage Mirroring scripts can take advantage of four flow control programming constructs.
IF conditional—The IF conditional expression is a comparison between two values or
variables. Use the following syntax for an IF conditional:
IF <relational expression> THEN <statement_block>
[ ELSE <statement_block> ] END
Use the following conditions to create the relational expression.
FOR Loop—The FOR loop sets a variable to a start value, executes each statement in the
statement block, and then adds the step value to the variable. If the new value of the variable
does not exceed the end value then the statements will be executed again. This continues until
the variable exceeds the end value. If a step value is not provided, the default adds one to the
variable. Use the following syntax for the FOR loop:
FOR <variable> = <start_value> TO <end_value>
[STEP <step_value>] DO <statement_block> END
WHILE Loop—The WHILE loop evaluates a relational expression and, if it is true, then the
statement block is executed. When the statement block has completed execution, the
expression will be reevaluated again and, if it is true, the statement block is executed again.
This continues until the expression is false. Use the conditions specified in the IF conditional
to create the relational expression and the following syntax for the WHILE loop:
WHILE <relational_expression> DO <statement_block> END
WRITE Command—The WRITE command writes values to the screen. These values can be
variables or constants of type integer$, string$, date$, or time$. The write command is used
in conjunction with either the IF conditional, WHILE loop, or FOR loop.
Each Storage Mirroring command and assignment must end with a semi-colon. However, no
semicolon is necessary after the END keyword for the IF conditional and the loop statements.
When using the Command Line Client, a script file can be executed using the -f option. Create
a one-line batch file using the following command to initiate the Storage Mirroring Command Line
Client with the
-f option and specify the name of the script to execute.
cmd /c DTCL -f "/usr/bin/scriptname"
If you do not specify a path for the script file, Storage Mirroring will look in the directory where
the DTCL -f command was executed.
= Is equal to > Is greater than
!= Is not equal to >= Is greater than or equal to
< Is less than statement block
Any sequence of valid DTCL commands
<= Is less than or equal to