Options

Just found out about tclsh

PristonPriston Member Posts: 999 ■■■■□□□□□□
I'm surprised I haven't heard about tcl earlier. Seems like it could be useful when you want to ping a lot of stuff.

I've been playing around with it and wrote this script
puts [open "flash:pings" w+] {
puts ""
show clock
puts " --- Start pinging ---"
puts ""
foreach add {
10.7.52.1
10.7.53.1
10.10.10.1
10.100.10.22
10.7.42.1
10.7.42.5
} {
set output [exec "ping $add repeat 3"]
set addlength [string length $add]
set x [expr "$addlength" + 93]
set y [expr "$addlength" + 95]
if {[regexp "!" $output]} {puts "[string range $output $x $y] $add OK"
} else {puts "[string range $output $x $y] $add ***unreachable***"}}
show clock
puts " -- Pings stopped ---"
}

I couldn't figure out how to print the 3rd line in a string, so I had to calculate how many characters it is to the start and end of the 3rd line icon_sad.gif
here's the output from the script

R1#tclsh pings

*17:15:50.420 UTC Thu Aug 20 2015 --- Start pinging ---

!!! 10.7.52.1 OK
!!! 10.7.53.1 OK
... 10.10.10.1 ***unreachable***
... 10.100.10.22 ***unreachable***
!!! 10.7.42.1 OK
!!! 10.7.42.5 OK

*17:16:02.480 UTC Thu Aug 20 2015 -- Pings stopped ---

R1#
A.A.S. in Networking Technologies
A+, Network+, CCNA

Comments

Sign In or Register to comment.