Using The While Branch Command - Cisco 11503 - CSS Content Services Switch Administration Manual

Content services switch
Hide thumbs Also See for 11503 - CSS Content Services Switch:
Table of Contents

Advertisement

Chapter 8
Using the CSS Scripting Language

Using the while Branch Command

OL-5647-02
To execute the same commands repeatedly based on the result of an associated
expression, use the while branch command. When the expression results in a true
value (greater then 1), the script engine executes the commands within the branch.
If the result is a false value (denoted by the value of 0), then the script breaks out
of the loop and continues execution of all the commands following the endbranch
command. For example, enter:
set Counter "0"
while Counter "NEQ" "5"
echo "Counter is set to ${Counter}."
modify Counter "++"
endbranch
echo "We're done!"
The output of this logical block is:
Counter is set to 0.
Counter is set to 1.
Counter is set to 2.
Counter is set to 3.
Counter is set to 4.
We're done!
Until the expression is not satisfied, notice that the script jumps to the beginning
of the loop and evaluates the expression each time it reaches the endbranch
command. For the first five times through the loop, Counter is set to 0, 1, 2, 3, and
4, respectively, because the script continually increments the variable. However,
on the sixth time through the loop, Counter equals a value of 5, which does not
satisfy the expression "While Counter is not equal to 5". The expression produces
a false result, which causes the loop to terminate.
As with the if command, an endbranch command terminates a while command
logical block.
Using Logical and Relational Operators and Branch Commands
Cisco Content Services Switch Administration Guide
8-15

Advertisement

Table of Contents
loading

This manual is also suitable for:

11500 series

Table of Contents