TCL Script Help

Unanswered Question
Sep 2nd, 2010
User Badges:
  • Cisco Employee,


Some additional information....

After much troubleshooting today, I realized that the variable wasn't having a cast problem it was actually appending the router's hostname and # to the variable itself.  So instead of having "BottomsOspfCost = 20" was saying "BottomsOspfCost = 20 hostname#"

I have no idea why it was and is adding this hostname to the variable.  It seems to just be happening on values that we get from polling OIDs not on our local router.  For example, the OSPF oid that we poll from the adjacent router has it appended.


We are having trouble exporting a variable from a TCL script to EEM

##Creating the variable from the ospf request.  Getting the OSPF cost snmp into a variable

if [catch {cli_exec $cli1(fd) "snmp get v2c cisco timeout 1 oid ospfIfMetricEntry."} RESULT] {
  error $RESULT $errorInfo
  } else {
   set BottomsOspfCostGi03Request $RESULT

##Chopping that variable up to just get the cost info

set BottomsOspfCostGi03List [split $BottomsOspfCostGi03Request " "]
set BottomsOspfCostGi03Index [expr [llength $BottomsOspfCostGi03List]-1]
set BottomsOspfCostGi03 [lindex $BottomsOspfCostGi03List $BottomsOspfCostGi03Index]

Now that BottomsOspfCostGi03 should be our variable that has the OSPF cost in it.  HOWEVER, we can't use it as an integer inside the EEM, which is calling a tcl policy. 

So when we try to do the following, it throws errors:

set newGi03OspfCost [expr $BottomsOspfCostGi03 * 2]

Any help that you can provide will be muchly appreciated!

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
Joe Clarke Thu, 09/02/2010 - 22:05
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Why are you using CLI commands here?  You can use sys_reqinfo_snmp to query SNMP is a more programmatic fashion.

array set snmp_res [sys_reqinfo_snmp oid "ospfIfMetricEntry." get_type exact]

set newGi03OspfCost [expr $snmp_res(value) * 2]


This Discussion