[tkined] sample agent: snmpd-proc.tcl

Vincent Qing Yin (vyin@cs.ubc.ca)
Thu, 2 Jul 1998 17:31:01 -0700 (PDT)

Hi,

I'm have trouble understanding the sample snmpd-proc.tcl
under the scotty/tnm/agents directory:

proc SNMP_ProcInit {s} {
...
$s bind procReload.0 set {
1 ====> global procReload procID procCmd
2 ====> foreach id [array names proc] {
unset proc($id)
}
catch {unset cmd}
array set cmd [SNMP_GetPS]
foreach pid [array names cmd] {
%S instance procID.$pid proc(id,$pid) $pid
3 ======> %S instance procCmd.$pid proc(cmd,$pid) $cmd($pid)
}
set procReload [DateAndTime]
}
}

1) Does `global' statement actually create the global variable, if
it doesn't already exist? I don't see those three variables
referenced outside the procedure, so I assume they come into
existence when the procedure is called for the first time.
In any case, after calling that proc, I issued the command
% puts $procReload
can't read "procReload": no such variable
So where is procReload?

2) What is `proc'? Is that a _local_ array? I don't see that
referenced outside of the above procedure. If it were local, how
could it be used later on in the `%S instance' command?

3) What is the purpose of `proc(cmd,$pid)'? Does it only serve
as a place holder to keep track of what MIB instance we have
created, so that later we can `unset proc($id)'?

-- 

Q Vincent Yin | Repeat vyin@cs.ubc.ca | delete(next->bug); (604) 876-9096 (H) | Until 0 = 1;

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.