SecureCRT’s button bar is a customizable row of buttons you can use for quick access to saved actions and commands. To display the button bar, open the View menu and select Button Bar. By default, the button bar appears below the terminal screen. To hide the button bar, open the View menu and select Button Bar again.
To add a button, right-click on the button bar and choose New Button.
The Send String button function is used to send text or commands to a remote machine. You can send just about any text that you want, and there are unique commands (or codes) that can be used to instruct SecureCRT to send special characters like carriage return, newline, escape, tab, or backspace. The \p command code causes a one-second delay. A command code that is not listed here but is found in the SecureCRT Help is the \v command, which takes text from the clipboard and sends it to the connected machine. You can also send any ASCII character using a backslash followed by the character’s three-digit octal code.
This example uses SecureCRT version 6.7 connected to a Linux machine and starts at the remote shell prompt. First, you will create a button with a Send String function that will automatically open the vi editor, enable “insert” mode, and paste the contents of the clipboard.
In the Send String field, type the corresponding commands:
vi \r \p i \p \v \p \033
- vi is the remote editor to launch.
- \r simulates pressing the Enter key on the keyboard.
- A one-second pause with \p gives the vi application time to start.
- The i character, enables “insert” mode within the remote vi editor.
- Another one-second pause with a \p allows for vi to fully enter insert mode before any text from the clipboard is sent.
- The \v code sends the clipboard text to the remote machine.
- Another one-second pause \p is inserted to allow for a lengthy paste to complete.
- And finally, an Escape character is sent to take the remote vi editor out of ‘insert’ mode. Here we demonstrate the use of a 3-digit octal sequence with \033 (the octal code for the ASCII ESC character). The \e code could also be used .
- Give the button a label, and then press OK. The new button appears on the button bar.
- When the button is pressed, the “Send String” activity begins.
You can follow this basic pattern to create a library of buttons for running common commands you use frequently, or even complex commands that you don’t want to spend time remembering or reinventing.
The Run Script button function is used to extend the functionality of SecureCRT even further by running a script to perform customized actions. The installation of SecureCRT for Windows includes a number of example scripts. The script used in this demonstration takes any text selected in SecureCRT’s terminal screen and saves it to a file.
- Create a new button in the Map Button window with Run Script as the chosen function.
- Then, specify the SecureCRT script that this button will launch when pressed. SecureCRT’s file browser is currently in the program files location for SecureCRT, inside the Scripts sub-folder. This folder contains the example script mentioned earlier, which is named, “SaveSelectedTextToFile”. Give the button a label and press OK. The new button will appear on the button bar.
- To demonstrate how this particular script works in the video, we run the top command, select some text on the screen, and then press the script button previously created. When prompted, choose the default actions. Once the file has been written, the script opens the file for viewing with the default application.
Now that you’ve seen the Send String and Run Script button functions in action, we show you a few more extras regarding the SecureCRT button bar.
Up to this point, we’ve been interacting with the “Default” button bar, which always exists in SecureCRT. You can create additional button bars named to reflect your specific needs. To create a new button bar, right-click anywhere within the “Default” button bar and choose the New Button Bar… menu item.
Not only can you create a number of different button bars, but you can also associate session configurations with an initial button bar that will be activated automatically when a session is connected (or when a tab with that session is activated). This example has two different sessions: “Remote Machine” and “Linux Server”. The “Remote Machine” session is configured with the option to show the “Configs” button bar.
On the other hand, the “Linux Server” session is configured with the option to show the “Logs” button bar.