tclsh--用来处理Cisco IOS Shell脚本. 脚本可事先用Notepad编辑好,再往CLI控制台里一贴。不是所有的IOS都支持脚本,在12.2(25)S以上的版本才可以。
--------------------------------------------
Router#tclsh
Router(tcl)#proc Test-ping {} {
+>foreach ip {
+>1.1.1.1
+>2.2.2.2
+>} {ping $ip}
+>}
Router(tcl)#Test-ping
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 = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Router(tcl)#exit
Router#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset administratively down down
FastEthernet0/1 unassigned YES unset administratively down down
FastEthernet1/0 unassigned YES unset administratively down down
FastEthernet2/0 unassigned YES unset up down
FastEthernet2/1 unassigned YES unset up down
FastEthernet2/2 unassigned YES unset up down
FastEthernet2/3 unassigned YES unset up down
FastEthernet2/4 unassigned YES unset up down
FastEthernet2/5 unassigned YES unset up down
FastEthernet2/6 unassigned YES unset up down
FastEthernet2/7 unassigned YES unset up down
FastEthernet2/8 unassigned YES unset up down
FastEthernet2/9 unassigned YES unset up down
FastEthernet2/10 unassigned YES unset up down
FastEthernet2/11 unassigned YES unset up down
FastEthernet2/12 unassigned YES unset up down
FastEthernet2/13 unassigned YES unset up down
FastEthernet2/14 unassigned YES unset up down
FastEthernet2/15 unassigned YES unset up down
Vlan1 unassigned YES unset up down
Loopback0 1.1.1.1 YES manual up up
Loopback1 2.2.2.2 YES manual up up
------------------------------------------------
脚本只是临时保存,退出tcl后将消失。