8-9
Cisco Content Services Switch Administration Guide
OL-5647-02
Chapter 8 Using the CSS Scripting Language
Using Variables
To use a variable, you must supply a variable indicator to allow the CLI to
recognize the variable. The CLI searches each line of text it processes for the
variable indicator “$”. The next character
must
be the left brace character ({)
followed by the variable name. You terminate the variable name with the right
brace character (}). For example, if you want to print your variable to the screen
using the
echo
command, enter:
set MyVar “CSS11506”
echo “My variable name is: ${MyVar}”
The output is:
My Variable name is: CSS11506
Variable Types
The CLI stores a variable as either type integer or character. The CLI determines
a variable's type by the alphanumeric characters in its value. If any non-numeric
characters are present, the variable's type is character. If all the characters are
numeric, the variable’s type is integer.
Arithmetic operations on quoted numbers such as “100” are possible, but are not
possible on variables like “CSS11506” because the CLI knows that “CSS11506”
is not a numeric value. You can retrieve the variable type by appending [*] at the
end of the command string. For example, enter:
set MyVar “CSS11506”
echo “My variable type is ${MyVar}[*].”
set Number “100”
echo “My variable type is ${Number}[*].”
The output from this script is:
My variable type is char.
My variable type is int.
“Int” means integer (numeric with no decimal precision) and “char” means
character (any printable ASCII character). Anything that is not an integer is a
character. A variable that is defined as “3.14” is a character because the CLI does
not consider a period (.) to be a number.
Содержание 11500 Series
Страница 16: ...Contents xvi Cisco Content Services Switch Administration Guide OL 5647 02 ...
Страница 18: ...Figures xx Cisco Content Services Switch Administration Guide OL 5647 02 ...
Страница 120: ...Chapter 3 Configuring User Profiles Where to Go Next 3 16 Cisco Content Services Switch Administration Guide OL 5647 02 ...