VanDyke Software

Tips

Index

How to Send a Literal "\" character in a Send String Function for a Custom Button, Command, or Mapped Key

SecureCRT's feature set allows you to map a button, command, or a mapped key to a Send String function so that a pre-configured command can be sent to the connected device. But what if the command you want to send requires a literal \ character to be sent? How do you configure the Send String text to include a \ character?

For instance, consider the following example command:

kubectl get pods -n xxx | grep -vE "([0-9]+)/\1|Completed"

If you place this exact text in a Send String definition for a button, command, or mapped key, the \1 portion of the command will disappear. This is because the \ character in a Send String value is reserved for escaping special send string commands, which does not include \1. Here is a list of the currently-supported send string commands:

\r  =  Carriage return (ASCII 13/0xd/015, decimal/hex/octal)
\n  =  Newline/linefeed (ASCII 10/0xa/12, decimal/hex/octal)
\b  =  Backspace character (ASCII 8/0x8/010, decimal/hex/octal)
\e  =  Escape (ASCII 33/0x1b/027, decimal/hex/octal)
\t  =  Tab (ASCII 9/0x9/11, decimal/hex/octal)
\v  =  Pastes the clipboard contents
\p  =  Pauses for 1 second
\\  =  Sends a \ character
\nnn  =  Sends an arbitray octal code nnn

As seen in the above chart, to send a literal \ character as part of a Send String value, you use two consecutive \ characters, as in \\ .

You can also achieve sending a literal \ character by sending its octal equivalent \134 .

Screenshot showing backslash examples

Circling back to the original example command, the Send String field would need to be set as follows in order to achieve sending a literal \1:

kubectl get pods -n xxx | grep -vE "([0-9]+)/\\1|Completed"

VanDyke Software uses cookies to give you the best online experience. Before continuing to use this site, please confirm that you agree to our use of cookies. Please see our Cookie Usage for details.