Re: Get return is a list? Please help...

Juergen Schoenwaelder (schoenw@cs.utwente.nl)
Mon, 1 Jul 1996 21:00:16 +0200

"Martone Mike" <martonem@bah.com> wrote:

I am writing a script that needs the OID and the value of the OID. When I
do a
$sr get $oid
is the variable $oid a list? It isn't acting that way. On a lindex $oid
1.....etc. I get blanks back.
How do I extract the data (which is returned by {1.3.6.1.4.1.2.3.4.5.6.7.6
INTEGER 1}) or something like that.

I can't tell you what you have in $oid. In the context of a get
request, you can have a list of OIDs (note: a single OID is the same
as a list with a single element). The result of a get request is a
varbind list, where each varbind is itself a Tcl list containing the
OID, the type and the value. To extract the OID, just do

set vbl [$s get $oid]
set oid [lindex [lindex $vbl 0] 0]

which extracts the OID contained in the first varbind. See the example
scripts for more examples.

Juergen