Cisco Support Community
Showing results for 
Search instead for 
Did you mean: 

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

Cisco Employee

TCL Script Help


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!

Cisco Employee

Re: TCL Script Help

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]