08-05-2012 02:16 AM
Hello Experts!
Short question. Is it possible somehow to modify "send" command on Cisco IOS?
AccessServer#send 80
Enter message, end with CTRL/Z; abort with CTRL/C:
configure terminal
hostname R1
The problem is, that I want to send " ctrl + c" command over the TTY line (to stop any action before configuring that device) . If we type this command , on the active terminal window, - send command will be aborted.
If I can't modify ctrl+c shortcut which is used with the send command, maybe anyone can suggest TCL script to achieve this?
Thank you for your time!
Solved! Go to Solution.
08-05-2012 04:08 PM
Ah, I see the problem. No, changing the escape sequence will not work with the yes/no prompt. I'm not sure I see a solution using send (if Control+V Control+C doesn't work). However, you could use reverse telnet instead (i.e., telnet to the async line such as telnet 10.1.1.1 2011). With reverse telnet, you connect to the console, and can paste the commands you want. You can also use Control+C here since the escape sequence that matters is what is configured on the terminal.
08-05-2012 01:54 PM
Even with Tcl, the control+C character will be caught by send. I don't really follow what you're trying to do, though. What would the remote device do with control+C? That's not the default IOS escape sequence anyway. Can you provide an exact use case of what you want to achieve?
08-05-2012 02:49 PM
Hello Joseph! Good to see you !
I wan't to send a list of commands to the device with the "send" command.
If the device is not in privillege exec mode ( for example, if I wan't to load the full configuration ) ,- device will not accept these commands.
Also if the device is left, with the prompt of the "reload" command or any simillar commands, where we must answer yes or no.
Ctrl+c or Ctrl+z could interupt these commands, and bring the prompt directly to the privillege exec mode.
Is there a way to send something, that we could interupt any other commands?
08-05-2012 02:53 PM
Control+C isn't the only character that will abort those commands. You can use the the default IOS escape sequence of Control+^ (Control+Shift+6) to do this. You can also change the escape character using the "terminal escape-character" command (on the remote device). That should likely give you what you want without needing to send Control+C over the async session.
08-05-2012 02:59 PM
That's very helpful information Joseph! Terminal escape-character would work, but I would prefer if user on the remote device can't see or change any of these commands.
How could I send Control+^ (Control+Shift+6) to the remote device with the "send" command over async line?
08-05-2012 03:03 PM
You don't have to persist the escape character. You can enter "terminal escape-character" within the current session to override what is configured. If you want to stick with the default, the octal character is \036 and you can use Control+V Control+^ to create the sequence.
08-05-2012 03:14 PM
Mhm, I sent this command sequnce "Control+V Control+^ " to the one of tty lines.
On the remote device this command looks like this (***) :
System configuration has been modified. Save? [yes/no]: ***
% Please answer 'yes' or 'no'.
But nothing happens. Reload command is not aborted.
08-05-2012 03:18 PM
If you're going to type it in manually, try Control+^ by itself (though I tried Control+V Control+^ locally and it seemed to work). If it doesn't work for you, change the escape sequence on the remote device. That's about all you're going to be able to do.
08-05-2012 03:32 PM
But anyway, "escape character" does not behave simillar like "Ctrl+c" command? With Ctrl+c we can abort command instantly.
If we talk about default "escape character", "Ctrl+^, X" or any other, these can't abort any prompts where we are asked for the answer? (yes or no I mean in the prompt))
08-05-2012 04:08 PM
Ah, I see the problem. No, changing the escape sequence will not work with the yes/no prompt. I'm not sure I see a solution using send (if Control+V Control+C doesn't work). However, you could use reverse telnet instead (i.e., telnet to the async line such as telnet 10.1.1.1 2011). With reverse telnet, you connect to the console, and can paste the commands you want. You can also use Control+C here since the escape sequence that matters is what is configured on the terminal.
08-05-2012 10:40 PM
Yes, this would work with reverse telnet. I just thought maybe there is a way to automate this process a bit.
Thanks for clarifying things.
Thank you for your time!
08-06-2012 07:06 AM
You can automate reverse telnet. I have an EEM package called the Remote Command Shell available from the downloads area at http://www.cisco.com/go/easy that can do this. This package is part of our Embedded Automation Systems initiative and can be installed using the EASy Installer available from the same location. This is just one example, but you could build a more tactical one using EEM to automate talking over the telnet connection.
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: