天天看點

拍錯技巧tcl腳本制作批量操作

  在生産環境中,通常要進行拍錯,大家都知道思科交換機用的IOS是基于unix系統的,是以在操作中也可以通過在CLI模式下執行簡單腳本節約拍錯時間,一路由器R1為例,批量執行ping腳本如下:

router#tclsh

router(tcl)#

R1(tcl)#foreach address {

+>(tcl)#10.1.1.1  //為所要ping的位址

+>(tcl)#10.1.2.1

+>(tcl)#10.1.3.1

+>(tcl)#10.1.4.1

+>(tcl)#10.100.12.1

+>(tcl)#10.100.12.2

+>(tcl)#10.2.1.1

+>(tcl)#10.2.2.1

+>(tcl)#10.2.3.1

+>(tcl)#10.2.4.1

+>(tcl)#} {

+>(tcl)#ping $address

+>(tcl)#} //回車就會看到如下效果

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/8 ms

Sending 5, 100-byte ICMP Echos to 10.1.2.1, timeout is 2 seconds:

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/8 ms

Sending 5, 100-byte ICMP Echos to 10.1.3.1, timeout is 2 seconds:

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/6/12 ms

Sending 5, 100-byte ICMP Echos to 10.1.4.1, timeout is 2 seconds:

Sending 5, 100-byte ICMP Echos to 10.100.12.1, timeout is 2 seconds:

Success rate is 100 percent (5/5), round-trip min/avg/max = 56/61/68 ms

Sending 5, 100-byte ICMP Echos to 10.100.12.2, timeout is 2 seconds:

Success rate is 100 percent (5/5), round-trip min/avg/max = 28/30/36 ms

Sending 5, 100-byte ICMP Echos to 10.2.1.1, timeout is 2 seconds:

Success rate is 100 percent (5/5), round-trip min/avg/max = 28/31/36 ms

Sending 5, 100-byte ICMP Echos to 10.2.2.1, timeout is 2 seconds:

Sending 5, 100-byte ICMP Echos to 10.2.3.1, timeout is 2 seconds:

Success rate is 100 percent (5/5), round-trip min/avg/max = 28/32/36 ms

Sending 5, 100-byte ICMP Echos to 10.2.4.1, timeout is 2 seconds:

Success rate is 100 percent (5/5), round-trip min/avg/max = 28/32/36 m

繼續閱讀