Executing multiple IOS commands one after the other with a delay

Unanswered Question
Aug 11th, 2010

Hi -

As part of my monitoring solution, I have scheduled scripts running on my routers to do various tasks, now I am trying to do trace route to about 10 routers from a seed router to track the path of the trace and if it changes i would be alerted.

What I am having difficulty is doing one trace commands from a text file. Example follows:




The command will stop right after the first line, is there a way in IOS to do a “wait” statement between each command to get this going?


Daya Rajaratnam

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
Joe Clarke Wed, 08/11/2010 - 23:31

You can use Tcl for this.  With Tcl, you can use the "after" command to insert a delay between each command:


after 3000


after 3000


That will add a 3 second delay between each command.

dayar Sun, 08/15/2010 - 13:24

Great Thank Joseph -

Some of the limitation I have with TCL is it requires IOS 12.3.2 train or higher and also I believe you need to be in enable mode?

Joe Clarke Sun, 08/15/2010 - 13:55

Correct, you need 12.3(2)T or higher (for router IOS).  Tcl is also available in many other non-router platforms.  Yes, you do need to be enabled. for tclsh.  For EEM, though, you do not need to be enabled.  You can register an EEM policy, then anyone on the box can execute it.  EEM is also built around Tcl, so the same code could be added to such a policy.  For example:


namespace import ::cisco::eem::*

namespace import ::cisco::lib::*

array set cliarr [cli_open]

set output {}

foreach host [list x.x.x.x y.y.y.y z.z.z.z] {

    append output [cli_exec $cliarr(fd) "traceroute $host"]

    after 3000


cli_close $cliarr(fd) $cliarr(tty_id)

puts $output

EEM Tcl policies require 12.3(14)T or higher for router IOS.


This Discussion