cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
613
Views
0
Helpful
0
Replies

How to get value of snmp index outputs in TCL

mhdganji110
Level 1
Level 1

I need a script to find all disabled ports (ifAdminStatus=1) and un-shut them (or any other action) The problem is I cannot get the value by if command. Seems I'm missing something.

As you can see the value of ifAdminStatus for interface with index 20 is 1

...

Router(tcl)#snmp_getone Public ifAdminStatus.20
{<obj oid='ifAdminStatus.20' val='1'/>}

...

But I cannot get it with an If statement. Tested following syntaxes but did not succeed

...

Router(tcl)#
Router(tcl)#if {snmp_getone Public ifAdminStatus.20 ==1 } {puts "Value=1"}syntax error in expression "snmp_getone Public ifAdminStatus.20 ==1 "
Router(tcl)#
Router(tcl)#if {'snmp_getone Public ifAdminStatus.20' ==1 } {puts "Value=1"}syntax error in expression "'snmp_getone Public ifAdminStatus.20' ==1 "
Router(tcl)#if {[snmp_getone Public ifAdminStatus.20] ==1 } {puts "Value=1"}

...

I just like to have 1 returned if the value is 1. Then I should extend it to all ports and make array of interfaces, making actions, etc.

Any help would be appreciated.

0 Replies 0