03-22-2012, 07:10 PM
VanDyke Technical Support
Join Date: Nov 2003
Location: Albuquerque, NM
This specialized thread posting contains example scripts that can be used with VanDyke Software products, focusing primarily on SecureCRT.
Script examples are attached 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. You are encouraged to provide feedback related to 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.
Watch the video: Color Schemes and ANSI Color Palettes
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.
Get Configuration Path
Shows how to acquire the folder/directory from which SecureCRT is loading/saving configuration settings. Cross-platform Python example will work in SecureCRT on both Windows and Mac/Linux platforms. VBScript example will work only in SecureCRT on Windows.
Get Tab By Name
Shows how to get a reference to a tab object by supplying the tab name. Examples provided for both VBScript and python.
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 Keyword Highlighting INI File in SecureCRT
This example demonstrates an easy way to import a Keyword Highlighting INI file into SecureCRT.
Watch the video: Keyword Highlighting in SecureCRT -- Watch the video: Importing a Keyword INI File into SecureCRT
Import Putty Connections to SecureCRT Saved Sessions
Pretty self-explanatory: Imports putty configurations into SecureCRT saved sessions. Different example scripts are available to import from putty, mputty, putty-cm, and super putty.
Integrating with Microsoft Excel
Several examples demonstrating use of Excel to read, write or search for data.
Launch RDP or HTTP Connections from SecureCRT Sessions
An approach to managing RDP/HTTP/HTTPS connections from within SecureCRT's session manager.
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.
Open SecureCRT's Log File/Folder
Shows how a script can be launched from a button to open SecureCRT's log file/folder.
Paste (or Send ASCII File) With Echo Flow Control
Demonstrates how to send data from the clipboard (or read in from a file) 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.
Python - Importing custom modules which reference the crt object
Examples showing techniques for importing your custom-written python modules which need to reference the crt scripting object.
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.
Send Lines One by One with Skips and Substitutions
An example which brings up a separate UI allowing you to control the sending of lines, one by one, as read in from a file. You can define substitution variables, allowing you to leverage the same sequence of lines, but with different values in specific places. If the current line is one you want to skip, just press the Skip button to move on to the next one.
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.
Watch the video: The SFTP Tab in SecureCRT
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).
TAPI Replacement Dialer - Use Serial
This Windows-only example script shows one alternative to using TAPI. It uses the Serial protocol to connect to the COM port of your modem, and does the dialing instead of farming the job off to the Windows TAPI system.
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.
Last edited by jdev; 11-18-2019 at 02:09 PM.
Reason: Added TAPI Replacement Dialer example