Cisco 11503 Administration Guide - Page 301
exit script, Because the script contains an
UPC - 746320664958
View all Cisco 11503 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 301 highlights
Chapter 8 Using the CSS Scripting Language Syntax Errors and Script Termination For example, enter: ! Exit Cleanly exit script 0 There may be some cases where you want to indicate that a script failed to run properly. One example of this is when your script requires that a user enter one or more command line arguments. There is no syntax checking that will prove that the user supplied the correct arguments, but you can check if the user supplied the correct number of arguments. For example, enter: if ${ARGS}[#] "NEQ" "2" echo "Usage: PingScript \'HostName\'" exit script 1 endbranch If this script fails to find exactly two arguments on the command line, it exits with status code 1 (failure). If you were to check the STATUS variable at this point, it would be set to a value of 1. Note All commands in the CLI write an exit code to the STATUS variable after they execute. If you want to use the STATUS value, you must save it in another variable or use it right away. For example, enter: script play PingScript echo "Status: ${STATUS}" echo "Status: ${STATUS}" The output is: Usage: PingScript "HostName" Status: 1 Status: 0 Because the script contains an exit script command with a value of 1, the first echo command returns a STATUS value of 1 to indicate that the script failed. The second echo command returns a STATUS value of 0 because the first echo command executed successfully. OL-5647-02 Cisco Content Services Switch Administration Guide 8-33