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 will need to change the extension from .txt to either .vbs or .py depending on whether the example is a VBScript or Python example, respectively.
The purpose of these examples is to provide you with a starting point for creating your own scripting solution. Although a script example might appear to do "exactly what you need", the scripts listed here will almost always need to be modified to meet your own specific needs
It's currently a work in progress; this "sticky" thread is closed to feedback in order to prevent it from becoming difficult to read/search. VanDyke Software technical support staff might periodically post new examples and update existing ones. Please 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
This example script is 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
This example script 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 to show you 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. This script can be used to format text in the clipboard prior to pasting *into* SecureCRT (having been copied to the clipboard within another application), or for copying *from* SecureCRT (and then converted so it's ready to be pasted into another application). It can also be used simply as a mechanism for reviewing/modifying what's currently in the clipboard prior to it being sent to a remote machine. Demonstrates one way of building a customized window/dialog using IE and handling user interaction within the custom dialog (see the VBScript user guide here: http://www.vandyke.com/support/tips/...ing/index.html)
Import Arbitrary Data From File To SecureCRT Sessions
This example shows how to create sessions from information in a text file (.csv format by default, but this can be edited 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 example scripts that demonstrate using 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. This is one approach to prevent overwhelming remote hosts like cisco devices that don't implement any SSH flow control and therefore are incapable of accepting data as fast as SecureCRT normally sends it.
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
This example script that 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
An example script making 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
This example script 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
This example script shows one way of cycling through different delimiter sets for double-click word selection. Simply open SecureCRT's button bar and map a new button to run this script. Every time you press the button, SecureCRT's word delimiters for that particular session will change, rotating through 5 different word delimiter sets -- one of which being the set defined in Global Options.