The index_if_array argument will be ignored when the var argument is a scalar variable.Note
If var is unspecified, retrieves the whole variable table saved in the context.
If var is specified and index_if_array is not specified, or if index_if_array is specified but var is a scalar
variable, retrieves the value of var.
If var is specified, and index_if_array is specified, and var is an array variable, retrieves the value of the
specified array element.
Result String
Resets the Tcl global variables to the state that they were in when the save was performed.
Set _cerrno
•
A string displaying _cerrno, _cerr_sub_num, _cerr_sub_err, _cerr_posix_err, _cerr_str due to appl_reqinfo
error.
•
Variable is not in the context.
Sample Usage
The following examples show how to use the context_saveand context_retrieve command extension
functionality to save and retrieve data. The examples are shown in save and retrieve pairs.
Example 1: Save
If var is unspecified or if a pattern if specified, saves multiple variables to the context.
::cisco::eem::event_register_none
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
set testvara 123
set testvarb 345
set testvarc 789
if {[catch {context_save TESTCTX "testvar*"} errmsg]} {
action_syslog msg "context_save failed: $errmsg"
} else {
action_syslog msg "context_save succeeded"
}
Example 1: Retrieve
If var is unspecified, retrieves multiple variables from the context.
::cisco::eem::event_register_none
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
if {[catch {foreach {var value} [context_retrieve TESTCTX] {set $var $value}} errmsg]} {
action_syslog msg "context_retrieve failed: $errmsg"
} else {
action_syslog msg "context_retrieve succeeded"
}
if {[info exists testvara]} {
action_syslog msg "testvara exists and is $testvara"
} else {
action_syslog msg "testvara does not exist"
Consolidated Platform Configuration Guide, Cisco IOS Release 15.2(4)E (Catalyst 2960-X Switches)
1862
context_retrieve