cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2619
Views
0
Helpful
3
Replies

Send message to all VTY lines with Tcl

Corbin Murrow
Level 1
Level 1

I am attempting to write a Tcl script that includes messaging out to all vty lines when certain events are about to occur. I am having trouble figuring out how to use exec "send *" because I cannot issue the entire send command in one line. After issuing "send *" it wants me to type the message and terminate it with CTRL+Z. It also seems to block the script execution until the event is resolved.

I tried to get around this by use of the "after" command. I tried "after 1000 puts [format %s "Test \0312"] and then issuing send * after that command but both "after" and "send *" are blocking.

If anyone knows of a way to issue a non-blocking "send *" or "after" command I would appreciate the help. Or, if anyone knows of a different way to achieve my goal I would love to hear it.

I am trying to avoid using an EEM script as I intend to run this Tcl script off of a FTP/TFTP server that I control on equipment not controlled by me. Therefore, I will not be able to enter configuration mode to input all the EEM stuff.

3 Replies 3

Joe Clarke
Cisco Employee
Cisco Employee

I doubt you'll make this work anymore on modern IOS.  Tclsh was never good at interactive commands anyway.  The sequence:

typeahead "Test\032\015" ; exec "send *"

Used to work, but it doesn't any longer.  Modern IOS also restricts tclsh to priv 15, so I'm surprised you wouldn't have config access but be able to run Tcl.  My suggestion to you would be to run this script off-box and use Expect to interact with the "send *" command.

Thanks for the response. Bummer that it's not really possible anymore to do this with tclsh.

Regarding not having config access: I wasn't super clear in my first post. It's not that my account doesn't have priv 15, but that I have an agreement not to touch configuration mode on the switches when doing my network discovery work with the Tcl scripts.

If I didn't have a config mode restriction, would it be possible to trigger a message to all VTY lines using EEM? I know nothing about EEM, I've focused my learning almost solely on Tcl but I am interested in learning. If so, perhaps you can point me in a direction to start learning/looking?

I am currently looking now at using Expect to interact with the send command as well, thanks for the pointer.

With EEM you could do this with an applet:

event manager applet send-all

 event none

 action 1.0 cli command "enable"

 action 2.0 cli command "send *" pattern "Enter"

 action 3.0 cli command "This is a test\032" pattern "confirm"

 action 4.0 cli command "\015"