Scripting Examples

Example Scripts for SecureCRT® for Windows

The following scripts, written in VBScript, JScript and PerlScript, are examples of how to perform specific tasks using the script execution capabilities of SecureCRT for Windows. They can also be used as a guide to writing your own scripts.

The scripts are collected in one self-extracting EXE file, which you can download by clicking on the link below. The list below describes the different scripts in the file.

For more information on scripts and scripting methods, see the Scripting FAQ and the VanDyke Software online Scripting Essentials guide.

example scripts.exe (48K)

Connecting From Within a Script

Connect to a server using a pre-defined session (JScript).
Connect with SecureCRT using the SSH2 protocol (VBScript).
Connect using the telnet protocol and automate login (VBScript).

Sending Commands and Data To a Server

Opens a file and sends its contents line by line (VBScript and JScript respectively).
Opens a file and does some processing of the text before sending it (VBScript).
Uploads a text file to a server by sending it line by line and directing output to a file (VBScript).
SetEnv.vbs Automates setting the DISPLAY shell variable to enable remote display of X clients (VBScript).
SetLinesCols.vbs Automates setting the LINES and COLUMNS shell variables for terminal environments where these variables are not set properly (VBScript).
SendFKey.vbs Simulates pressing a function key (VBScript).

Retrieving Output From a Server

GetData.vbs Demonstrates use of the Get() function to read data from the screen (VBScript).
GetDataToExcel.vbs Uses the Get() function to read data from the screen and uses OLE automation to write data to an Excel file (VBScript).
GetDataToFile.vbs Uses the Get() function to read data from the screen and write it to a text file (VBScript).

User Interface Functions


Demonstrates the various uses and options of the MessageBox() function (VBScript and JScript).


Demonstrates the use of the Prompt() function (VBScript and JScript).

Sharing Script Code

These paired scripts show a convenient way of structuring both VBScript and JScript code so that common functions can be reused or shared by more than one script (VBScript and JScript).

Miscellaneous Scripts

WinEnv.vbs Retrieves some Windows user environment variables via Windows Scripting Host (WSH) (VBScript).
Runs an external program from a session via WSH (VBScript and JScript).
RunWord.vbs Run MS Word via Word's OLE automation interface (VBScript).
StartLogfile.vbs Sets the logfile name and enables logging from a script (VBScript). Simple login script (PerlScript). Logs on to several UNIX servers to run some commands (PerlScript).