Cisco 11503 Administration Guide - Page 302
Exiting a Script Within Another Script, Using the grep Command
UPC - 746320664958
View all Cisco 11503 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 302 highlights
Using the grep Command Chapter 8 Using the CSS Scripting Language Exiting a Script Within Another Script It is possible to play a script from another script using the function SCRIPT_PLAY. For details on playing a script, see "Using the SCRIPT_PLAY Function" earlier in this chapter. In this case, be careful when dealing with the exit script command in the secondary script. If script A invokes script B and script B issue an exit script command, both scripts will exit. Therefore, it is important that a script calling another script either removes any exit script commands in the second script or makes other arrangements to handle this behavior. Using the grep Command To search for specified data and place the last line of the search results in a variable called UGREP, use the grep command with the -u option. For example, to create a script to search for the Keepalive field in the show service command on a service called S1, enter: !no echo show service S1 | grep -u "Keepalive" echo "The line is: ${UGREP}" The output is: The line is: Keepalive: (SCRIPT a-kal-pop3 10 3 5) Because the show service screen contains the field Keepalive, the entire line is stored in the UGREP variable. You can also extract each space-separated element by treating the UGREP variable as an array. For example, to extract the first block of text, enter: !no echo show service S1 | grep -u "Keepalive" echo "The first element in the line is: ${UGREP}[1]" The output is: The first element in the line is: Keepalive: 8-34 Cisco Content Services Switch Administration Guide OL-5647-02