snmp# set
vbl [script]
The snmp# set session command
can be used to create and modify MIB instances. The varbind
list vbl for set-requests must contain at least the object
identifier and the new value as described above.
If the set session command
contains a callback script, then the command
sends the set-request and returns immediately. The result is the request
id for the asynchronous request.
The set session command is
processed synchronously if the callback script is absent. In this case,
the received varbind list is returned.
The command fails with a
Tcl error if the agent does not respond or if a protocol error happens.
Below is a synchronous example
that shows how you can change the sysContact.0 and sysLocation.0 variables
of the system group.
set vbl [list \
[list SNMPv2-MIB!sysContact.0
“Bert Nase”]\
[list SNMPv2-MIB!sysLocation.0
“Hall6, Floor 5”]\
]
set err [catch {$s set $vbl}
vbl]
if {$err == 1} {
exit 1
}
Note that it is always recommended
to use the Tcl list command to build the
varbind list. This makes sure that quoting is done in the correct way.
The asynchronous version of the command looks as follows:
set vbl [list \
[list SNMPv2-MIB!sysContact.0
“Bert Nase”]\
[list SNMPv2-MIB!sysLocation.0
“Hall6, Floor 5”]\
]
$s set $vbl {
if {”%E” != “noError”}
{
exit
1
}
}
|