This specialized thread posting contains example scripts that can be used with VanDyke Software products.
Script examples are attached below as .txt files. After saving an example script file to your system, you may need to change the extension from .txt to either .vbs or .py depending on whether it's a VBScript or Python example.
The examples here merely provide you with a starting point for creating your own scripting solutions. Although a script example may appear to do "exactly what you need", the scripts listed here will almost always need to be modified to meet your own specific needs
This "sticky" thread is closed to feedback to prevent it from becoming difficult to read/search. VanDyke Software technical support staff may post new and update existing examples as time and resources allow. Provide feedback (questions, comments, suggestions) regarding these examples by email
, or a separate thread
in the scripting forum.
VBScript and Python Examples for SecureCRT
Cisco Save Running/Startup Config to Local File
Written in Python so as to be able to run on Windows/Linux/MacOSX versions of SecureCRT. If you're already connected to the device using SecureCRT, the script saves your Cisco router running-config or startup-config to a local file with the press of a button.
Close All But Current Tab
Illustrates how to close all open tabs. It is possible to modify the behavior of the script by passing arguments to the script. The script can be run manually from the Script menu or by mapping a button or key combination.
Color Scheme Scripting
Need to quickly adjust your colors based on existing color schemes defined in SecureCRT? Two example scripts show how you can save clicks while you enjoy rapid color scheme selection.
Command Window Automation
Demonstrates how to automate the Command Window (formerly known as the "chat window") in SecureCRT 7.2 and newer.
Connect in Tab to Host and Handle Authentication in Terminal Window
Prompts for host/IP, username, and password (if not hard-coded in the script variables strHost, strUser, and strPwd), and then uses the information to connect to the host using the SSH2 protocol. The session configuration object is used to detect if the option is enabled for handling authentication in the terminal window, and prompts the user to have this script automatically enable it if the option is not currently enabled. SSH2 authentication is handled by waiting for the username and password prompts and sending the username and password, respectively.
Convert Clipboard, LF, CR, Space, and Tab
Shows one way to convert certain characters within the windows clipboard prior to pasting to the remote or after being copied from the SecureCRT terminal window. A separate UI is displayed, offering options for conversion.
Import Arbitrary Data From File To SecureCRT Sessions
Shows how to create sessions from information in a text file (.csv format by default, but you can edit to fit the format you have).
Import Putty Connections to SecureCRT Saved Sessions
Pretty self-explanatory: Imports putty configurations into SecureCRT saved sessions.
Integrating with Microsoft Excel
Several examples demonstrating use of Excel to read, write or search for data.
Jump Host - Handle Secondary Host Connection Attempts
Connected to a jump host and want an example of automating 'ssh' or 'telnet' connection attempts from that remote shell to another system? This example shows you a best practice way to accomplish this task.
Paste With Echo Flow Control
Demonstrates how to send data from the clipboard to a remote system, sending each line one at a time and waiting for prior lines to be echoed back by the remote system before moving on with sending subsequent lines.
Reveal Non-Printing Characters
Demonstrates how to "reveal" non-printing characters that are present in the clipboard (CR, LF, etc. as examples of non-printing characters).
Run Commands On Multiple Hosts And Log Results
(AKA: Read Data From Separate Hosts/Commands File And Log To Individual Files)
Demonstrates how to connect to hosts read in from a "hosts" file and for each host, send a list of commands read in from a "commands" file. Results are logged to separate, uniquely-named files based on the host address and optionally the commands that are executed.
Save Screen Text to a File
Demonstrates how to easily/quickly save text from the screen/scrollback to a file. Three separate modes are available for deciding what text to save: selected text, all screen text, or all text on both screen & scrollback buffer.
Save Selected Text To CSV File
Allows you to quickly save columns of space-separated data selected in SecureCRT's terminal screen to a CSV file. Automatically launches the CSV file for viewing/editing in the system's default CSV app.
Set Trace Level
Shows how to set a more/less verbosity level for SecureCRT's "Trace Options" functionality. Often when troubleshooting a connectivity issue between client and server, it's helpful to know more about what's going on lower down in the protocol. If VanDyke Software technical support asks you to set Trace Level to a value greater than one, consider this script as an alternative to manually editing the .ini file.
SFTP Tab Automation
Demonstrates opening an SFTP tab & programmatically driving a file download. Prior to running this script, the currently active tab must already be connected with the SSH2 protocol to a remote server that is capable of providing SFTP functionality; otherwise an error will occur and script execution will be halted.
Store Command Results in the Clipboard
Example script which made an appearance in the Advanced Copy & Paste in SecureCRT video on our You Tube channel. It can be used to automatically copy results of remote commands into the clipboard (so you don't even have to spend valuable time selecting the results with your mouse).
Use 'Description' Field of Saved Sessions as Script Argument
Shows how you can use the "Description" field of a saved session to store data that you need to use somewhere within your script, but you don't want to hard-code it (because it might be session-specific, for instance).
Word Delimiter Rotation
Shows one way of cycling through different delimiter sets for double-click word selection. Having mapped a button on SecureCRT's button bar to run this script, SecureCRT's word delimiters for the active session particular session will change with each button press, rotating through 5 different word delimiter set examples.