Este script e bastante útil quando e necessário efetuar Pings durante o troubleshooting. Pode ser usado de uma forma casual ou através uma procedimento que poderá ser executado quando solicitado.
R1(tcl)#tclsh
! O “IP ” é uma variavel criada para o efeito
R1(tcl)#foreach IP {
+>172.22.1.1
+>172.26.1.6
+>} {ping $IP repeat 2 source loop0}
Type escape sequence to abort.
Sending 2, 100-byte ICMP Echos to 172.22.1.1, timeout is 2 seconds:
Packet sent with a source address of 172.21.1.4
!!
Success rate is 100 percent (2/2), round-trip min/avg/max = 8/12/16 ms
Type escape sequence to abort.
Sending 2, 100-byte ICMP Echos to 172.26.1.6, timeout is 2 seconds:
Packet sent with a source address of 172.21.1.4
..
Success rate is 0 percent (0/2)
!Caso nao executem o comando tclquit continuram em modo shell do TCL, fazendo parte
!do scritpt o texto digitado
R1(tcl)#tclquit
R5#tclsh
R5(tcl)#proc ping {} {
+>foreach IP {
+>172.22.1.1
+>172.29.1.2
+>} { puts [exec “ping $IP” ] }
+>}
! Executar o procedimento criado
R5(tcl)#ping
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.22.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/16/20 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.29.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/15/20 ms
!Caso nao executem o comando tclquit continuam em modo shell do TCL, fazendo parte
!do scritpt o texto digitado
R5(tcl)#tclquit