[Cisco IOS] Use TCL Ping Scripts on Cisco Routers for Reachability Testing

One common problem in networking is the lack of complete IP reachability to various segments of our network. Sometimes it can be difficult to dedicate enough time to properly verify that reachability exists between all relevant segments. In order to solve this problem two very useful features can be implemented, TCL scripting on the Cisco routers and macro scripting on Catalyst switches. For TCL scripting on the Cisco routers we can define the IP addresses as an array, and then use a “for” loop to run the ping command with the array as its argument. Specifically, we are defining the array “VAR”, which represents the IP addresses, then sending the exec command “ping” with “VAR” as the argument. NOTE: To actually run the script in IOS, we first must invoke the TCL shell. This is accomplished with the exec command “tclsh”.

March 24, 2015

foreach VAR {
} { puts [exec "ping $VAR"] }