Cisco 11503 Administration Guide - Page 283
Using the while Branch Command
UPC - 746320664958
View all Cisco 11503 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 283 highlights
Chapter 8 Using the CSS Scripting Language Using Logical and Relational Operators and Branch Commands Using the while Branch Command 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. OL-5647-02 Cisco Content Services Switch Administration Guide 8-15