Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Executing multiple IOS commands one after the other with a delay

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:

Trace 10.10.10.1

Trace 10.20.10.1

Trace 10.30.10.1

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?

Regards

Daya Rajaratnam

3 REPLIES
Cisco Employee

Re: Executing multiple IOS commands one after the other with a d

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

trace 10.10.10.1

after 3000

trace 10.20.10.1

after 3000

trace 10.30.10.1

That will add a 3 second delay between each command.

New Member

Re: Executing multiple IOS commands one after the other with a d

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?

Cisco Employee

Re: Executing multiple IOS commands one after the other with a d

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:

::cisco::eem::event_register_none

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.

1755
Views
0
Helpful
3
Replies