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 {
} {
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 ---

!!! OK
!!! OK
... ***unreachable***
... ***unreachable***
!!! OK
!!! OK

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

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


Sign In or Register to comment.