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
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.
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).
Integrating with Microsoft Excel
Several example scripts that demonstrate using Excel to read, write or search for data.
Paste With Echo Flow Control
Demonstrates how to send data from the Windows 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.
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 of each command run are logged to separate, uniquely-named files based on the host address and the command that is run.
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.
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.