Status Variable - 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

Special Variables

STATUS Variable

Note
Note
Cisco Content Services Switch Administration Guide
8-18
Use the STATUS variable to return the exit status of the previously executed CLI
command. In most cases, except for the grep command, an exit status of 0
indicates that a command was successful, while a non-zero value indicates that a
command failed. The CLI sets the STATUS variable automatically after each
command completes execution.
Using the grep command sets the STATUS variable equal to the number of lines
that satisfied the search. For details on the grep command, see
Command"
later in this chapter.
Typically, it is not necessary to examine the STATUS variable because a script
will terminate if a command does not execute properly. However, if you set the
CONTINUE_ON_ERROR variable, you can use the STATUS variable to test the
results of a command.
For example, enter:
set CONTINUE_ON_ERROR "1"
eco "Hello world"
if STATUS "NEQ" "0"
echo "Failure to execute command correctly"
endbranch
In the above example, the STATUS variable is set to a non-zero value. This value
is specific to the type of error that occurred. In this case, the script receives a
general syntax error, which informs you that the command being executed failed.
This is a typical example and one that you should watch closely when using the
CONTINUE_ON_ERROR variable. In most circumstances, you will want to
catch syntax errors as real errors.
When writing scripts, keep in mind that the value of the STATUS variable changes
as each command executes. If you intend to use a STATUS value later in a script,
you should save the value of the STATUS variable in another variable.
Chapter 8
Using the CSS Scripting Language
"Using the grep
OL-5647-02

Advertisement

Table of Contents
loading

This manual is also suitable for:

11500 series

Table of Contents