Building network automation solutions

9 module online course

Start now!

Insert responses to command prompts in Tclsh

I have been aware of the typeahead Tcl command for months, but somehow I never got it to work. It works perfectly in IOS release 12.4(15)T (it might have something to do with other fixes to Tclsh), so to clear interface counters (as Michal would like to do), this is what you can do:
typeahead "y"
exec "clear counter dialer 0";
Warning: if the input is not consumed by the executed commands, it stays in the typeahead buffer; quite dangerous if you have a sequence of commands, as the wrong command could be acknowledged.

An in-depth version of this article is available in the CT3 wiki.

You can find more Tclsh-related information in the Tclsh on Cisco IOS tutorial. Sample Tclsh scripts are available in the Tclsh script library. If you need expert help in planning, developing or deploying Tclsh scripts in your network, contact the author.

This article is part of You've asked for it series.

Add comment