TCL

Some TCL code, some of it I hacked (thanks to Google et-al). Some from trainings or my bootcamp:

This piece of TCL will ping a destination address using all available source addresses on the router:
# TCL
tclsh
!
proc ping_all {ip} {
if {[regexp "(!!)" [exec "ping $ip"]]} {

set counter 0
exec "term len 0"
set int [exec "show ip int brief"]
set length [llength $int]

puts "Djerk's amazing connectivity script..."
puts "Pinging $ip from all available source addresses"

while {$counter<=$length} {
set tmp [lindex $int $counter]

if {[regexp "(^\[0-9]+\.\[0-9]+\.\[0-9]+\.\[0-9]+)" $tmp ]} {
puts "\n"
puts "*** Ping from [lindex $int [expr $counter - 1]] ***"
exec "ping $ip source $tmp repeat 3 timeout 1"
}
incr counter
}
} else {
puts "\n\n"
puts "IP address $ip is not reachable\n"
set route [exec "show ip route $ip"]
puts "Output from the show ip route command\n"
puts "[exec "show ip route $ip"]"
}
exec "term len 24"
}

Example of use:
ping_all 172.29.64.6

This TCL script will ping all hard codes destinations:
tclsh
!
foreach address {
172.29.1.1
172.29.2.2
172.29.3.3
172.29.4.4
172.29.5.5
172.29.6.6
172.29.7.7
} {
ping $address
}
tclq

Parameters can be given, example: +>} { ping $i repeat 3 timeout 1 }

%d bloggers like this: