Cisco 11503 Administration Guide - Page 293
var-shift, command deletes the original data within the variable. The variable
UPC - 746320664958
View all Cisco 11503 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 293 highlights
Chapter 8 Using the CSS Scripting Language Using Arrays The output of this logical block is: Day: Sun Day: Mon Day: Tues Day: Wed Day: Thurs Day: Fri Day: Sat You cannot use a variable as the index to obtain a given element in an array. So the following statement is invalid: set Pet "Dog Cat" set Index "1" echo "First Pet is: ${Pet}[${Index}]" modify Index "+" 1 echo "Second Pet is: ${Pet}[${Index}]" However, the following statement can solve this problem: set Pet "Dog Cat" echo "First Pet is: ${Pet}[1]" var-shift Pet echo "Second Pet is: {$Pet}[1]" Notice in the second Pet example that there is one less variable needed (you do not need the Index variable) and the first element index (${Pet}[1]) is the only one used. The var-shift command deletes the original data within the variable. The variable Pet from the example above now contains only the element "Cat". To solve this problem, save the contents of the original variable in a temporary variable. For example, enter: set Pet "Dog Cat" set Temp "${Pet}" echo "First Pet is: ${Temp}[1]" var-shift Temp echo "Second Pet is: {$Temp}[1]" no set Temp By using the Temp variable, you leave the original variable untouched. If you decide you no longer need the Temp variable, remove it from memory with the no set command. OL-5647-02 Cisco Content Services Switch Administration Guide 8-25