EasyManuals Logo

Cisco 11503 - CSS Content Services Switch User Manual

Cisco 11503 - CSS Content Services Switch
392 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #282 background imageLoading...
Page #282 background image
Chapter 8 Using the CSS Scripting Language
Using Logical and Relational Operators and Branch Commands
8-14
Cisco Content Services Switch Administration Guide
OL-5647-02
Using the if Branch Command
To create a branch in a script based on the result of a previous command, use the
if command. If the previous result satisfies the expression in the if statement, the
script engine executes every line between the if and endbranch commands.
Otherwise, the script engine ignores the intervening commands and execution
continues following the endbranch statement.
set MyVar “1”
if MyVar “==” “1”
echo “My variable is equal to ${MyVar}!!!”
endbranch
if MyVar “NEQ” “1”
echo “My variable is not equal to 1 (oh well).”
endbranch
In the example above, the script tests the variable MyVar to see if it is equal to
“1”. If it is equal to this value, the echo command between the if command and
the endbranch command is executed. Note that the variable MyVar does not have
the typical variable indicator symbol ($) in front of it. This is because the if
command requires that a constant value or a variable name immediately follow the
command.
An exception to this rule applies when the if command references an array
element. In this case, you must use the normal variable syntax, including the
variable indicator ($) and the braces ({ }). For information on arrays, see “Using
Arrays” later in this chapter.
For example, the following logical block is valid:
if 12 “==” “${MyVar}”
echo “We made it!”
endbranch
However, this logical block is not valid:
if “12” “==” “${MyVar}”
echo “We made it!”
endbranch
Because the if command expects to see a constant or a variable name (without the
variable indicator), the text string “12” does not satisfy this requirement.
You can also test a variable for a NULL value. For example, enter:
if MyVar
echo “MyVar is equal to ${MyVar}”
endbranch

Table of Contents

Other manuals for Cisco 11503 - CSS Content Services Switch

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Cisco 11503 - CSS Content Services Switch and is the answer not in the manual?

Cisco 11503 - CSS Content Services Switch Specifications

General IconGeneral
BrandCisco
Model11503 - CSS Content Services Switch
CategorySwitch
LanguageEnglish

Related product manuals