RE: TCL Script

From: Victor Cappuccio (cvictor@protokolgroup.com)
Date: Wed Dec 14 2005 - 10:18:04 GMT-3


Nadeem please excuse my ignorance, but I thought that the show ip alias, was
necesary to be done in all routers and then generate a big TCL Script to
paste in each router

Regards
Victor.

-----Mensaje original-----
De: nobody@groupstudy.com [mailto:nobody@groupstudy.com] En nombre de Nadeem
Zahid (iszahid)
Enviado el: martes, 13 de diciembre de 2005 20:48
Para: ccielab@groupstudy.com
Asunto: TCL Script

I have written this script that frees you from copy past the sh ip alias
output from each router to a separate notepad
and extracting the ip addresses and then pasting into another script. It
does it all for you - if you can remember it...!
Just copy/past at each console

set ip {}
set add {}
set output [sh ip alias]
foreach line [split $output \r\n] {
if {[regexp "Interface" $line]} {
set ip [lindex $line 1]
lappend add $ip
puts $ip}
}
foreach ip $add {ping $ip}

* If first time it eats words while pasting - try one more time.

Output:
=====

Rack02R3(tcl)#set output [sh ip alias]
Address Type IP Address Port
Interface 148.1.3.3
Interface 148.1.0.3
Interface 150.1.3.3
Interface 148.1.35.3
Interface 192.10.1.3
Rack02R3(tcl)#foreach line [split $output \r\n] {
+>if {[regexp "Interface" $line]} {
+>set ip [lindex $line 1]
+>lappend add $ip
+>puts $ip}
+>}
148.1.3.3
148.1.0.3
150.1.3.3
148.1.35.3
192.10.1.3

Rack02R3(tcl)#foreach ip $add {ping $ip}

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 148.1.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 148.1.0.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/8 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 150.1.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 148.1.35.3, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.10.1.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms

Nadeem



This archive was generated by hypermail 2.1.4 : Mon Jan 09 2006 - 07:07:51 GMT-3