Command Line Interface User’s Guide
31
3.4.3
Advanced Scripting Concepts
The CLI provides the ability to perform environment variable substitution. Variable
substitution is the process of replacing a reference to the name of a variable with its actual
value. Variable substitution is useful in Python, Perl, Bash, or other scripts that invoke
predefined CLI script files and perform substitution at runtime.
The substitution syntax is
${varName}
, with the information typed between the curly
brackets specifying the variable name. Any time you use this syntax in a command line, the
CLI expects the variable name in curly brackets to be the name of a variable. If you want the
dollar sign preceding the first curly bracket to be interpreted as just a simple dollar sign,
precede it with the backslash (\) “escape” character.
Example 1: The following example shows how variable substitution might work with a bash
script. In this example, assume that a bash script has the following lines:
#!/bin/bash
export VolName=
"
MyNewVolName"
cli2 –x DeleteVolume
export VolName="Zeus"
cli2 –x DeleteVolume
Also, assume that
DeleteVolume.cli
contains the following line:
VolumeList.Volumes[${VolName}].Delete
In this example,
${VolName}
will be replaced with the volume named
Zeus
, which will be
deleted.
Example 2: The following example shows how the backslash character can be used to have
the CLI interpret a dollar sign character as just a simple dollar sign. In this example, assume
that an
ENV
variable called
envvar
equals
ABC
. In this case,
abc\${envvar}
becomes
abc${envvar}
, while
abc${envvar}
becomes
abcABC
.
Summary of Contents for xStack Storage DSN-4000 Series
Page 6: ...vi Preface...
Page 42: ...32 Chapter 3 Using the CLI This Page Left Intentionally Blank...
Page 56: ...46 Chapter 4 Global Action Commands This Page Left Intentionally Blank...
Page 86: ...76 Chapter 5 Supported CLI Commands and Properties This Page Left Intentionally Blank...
Page 97: ......