Chapter 8 Using the CSS Scripting Language
Special Variables
8-18
Cisco Content Services Switch Administration Guide
OL-5647-02
STATUS Variable
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.
Note
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
“Using the grep
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.
Note
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.
Содержание 11500 Series
Страница 16: ...Contents xvi Cisco Content Services Switch Administration Guide OL 5647 02 ...
Страница 18: ...Figures xx Cisco Content Services Switch Administration Guide OL 5647 02 ...
Страница 120: ...Chapter 3 Configuring User Profiles Where to Go Next 3 16 Cisco Content Services Switch Administration Guide OL 5647 02 ...