Tcl – Tool Command Language
Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface Loopback1 Router(config-if)#ip address 1.1.1.1 255.255.255.255 Router(config-if)#exit Router(config)# Router(config)#interface Loopback3 Router(config-if)#ip address 3.3.3.3 255.255.255.255 Router(config-if)#exit Router(config)#end Router# Router#tclsh Router(tcl)#foreach ip { +>1.1.1.1 +>2.2.2.2 +>3.3.3.3 +>} { +>ping $ip +>} Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 8/10/12 ms Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds: ..... Success rate is 0 percent (0/5) Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 8/10/12 ms Router(tcl)# Router(tcl)#foreach ip { +>1.1.1.1 +>2.2.2.2 +>3.3.3.3 +>} { +>if { [regexp "(!!!)" [exec "ping $ip timeout 1" ]] } { +>puts $ip +>} else { puts "$ip *** failed ***" } +>} 1.1.1.1 2.2.2.2 *** failed *** 3.3.3.3 Router(tcl)# Router(tcl)#exit Router#
Genious!
ReplyDeleteYo Yap sifu, do you intend to write a regexp tutorial?
ReplyDeletehi Cyrus, the CCNP ROUTE Complete Guide already got some good tutorial on regex. Yes, I will also copy paste to make some blog posts. :p
ReplyDeleteDO you know how to create this script for N7K NX-OS??? Pls email to mikek07@gmail.com
ReplyDelete