SecureCRT

Scripting Examples

Example Python Scripts for SecureCRT® for Windows and macOS

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

Connecting From Within a Script


Connect with SecureCRT using the SSH2 protocol.
Connect using the telnet protocol and automate login.
 

Sending Commands and Data To a Server


AutoResponder.py Set up a list of commands or text to send to the remote when a corresponding trigger is detected.
MultiSessionSend.py Connects to multiple sessions and sends a series of commands.
ReadString.py Captures the output of the 'ls' command and displays it in a message box.
SendCommandsToTabs.py Sends the same command to all tabs that currently have an active connection.
Opens a file and sends its contents line by line.
Opens a file and does some processing of the text before sending it.
Uploads a text file to a server by sending it line by line and directing output to a file.
SetEnv.py Automates setting the DISPLAY shell variable to enable remote display of X clients.
SetLinesCols.py Automates setting the LINES and COLUMNS shell variables for terminal environments where these variables are not set properly.
SendFKey.py Simulates pressing a function key.
 

Retrieving Output From a Server


CopyToClipboard.py The results of specific commands are captured and stored in the clipboard.
GetData.py Demonstrates use of the Get() function to read data from the screen.
GetDataToExcel.py Uses the Get() function to read data from the screen and write data to a spreadsheet file.
GetDataToFile.py Uses the Get() function to read data from the screen and write it to a text file.
LogCommandOutput.py The results of specific commands are written to log files.
 

Miscellaneous Scripts


AddCommentToLog.py Prompts for a comment to add to the log file.
SaveSelectionToFile.py Saves the selected text to a file.

VanDyke Software uses cookies to give you the best online experience. Before continuing to use this site, please confirm that you agree to our use of cookies. Please see our Cookie Usage for details.