![]() |
![]() |
| Home | What's New | Products | Download | Purchase | Support | About Us | Contact |
SUPPORT > TIPS
|
|
|
|
Importing SecureCRT® Sessions from a Data FileNote: This tip is for use with SecureCRT for Windows® and provides example scripts that use VBScript. Recreating your SecureCRT sessions can be easy if you keep a list of the servers, routers, and other devices that you need to connect to saved in a .csv or other type of data file. With a data file, you can use a script to import the data into SecureCRT sessions, rather than manually creating them one at a time. In this tip, we explain how to set up an example data file, and we provide an example VBScript for you to use and modify for your specific setup. You only need a few basic script-writing skills to get started (more extensive knowledge may be required to customize the example script to meet your needs). The example script gathers information about your host machines from your .csv data file in order to create the .ini files that will become your SecureCRT sessions. There are comments within the script code explaining the expected format and organization of the data file. The comment lines in the script begin with a single quote character (') and, as comments, they do not affect the functionality of the script. The following steps show you how you might use the techniques described in the script to generate sessions from your data file. Setting up the data fileThe first thing you'll need is a data file that contains the host information. The format below most closely matches the format that the script uses. If your data file only includes some of the information, you can edit the script so that it only looks for the items that you actually have in the data file. The following is an example of what your data file might look like: hostname,protocol,username,folder,emulation192.168.0.1,SSH2,root,Linux Machines,XTerm 192.168.0.2,SSH2,root,Linux Machines,XTerm 10.0.100.1,SSH1,admin,CISCO
Routers,VT100 myhost.domain.com,SSH2,administrator,Windows Servers,VShell 555-1212,tapi,n/a,TAPI Sessions,VT100 The first line names the fields used and their order. This example uses a comma as the delimiter between fields, but the script can work using a comma, space, semicolon, or tab as the delimiter. If your delimiter character is not a comma, you can "comment out" line 58 of the script by inserting a single quote at the beginning of the line, and then remove the comment character from the beginning of one of the subsequent lines that matches your delimiter character. Or, simply modify the value of the g_strDelimiter variable on line 58 to match your specific delimiter character(s). Note: The value of the emulation field must match a valid SecureCRT emulation option as displayed in the Terminal option in the Terminal / Emulation category of the Session Options dialog. The only protocol not currently handled by the example script code is the Serial protocol. If you need to import a large number of Serial session configurations, take a look at how the script code handles TAPI data, as it may give you some ideas about script modifications you might be able to put in place to meet your importing needs. The field keywords that the script can already use are as follows:
The example data file above doesn't include a session_name field, so the hostname information will be used as both the hostname and the session name. If you look at line 87 of the example script, you will see that, by default, the script is expecting the data file to be named MyDataFile.csv and to be located in C:\Temp\MyDataFile.csv. You can either move and rename your data file to match the name and location in the example script, or you can edit that line of code in the script to point to your data file. If you look at lines 141-143 of the script, you will see that the script reads the current user's registry to find the location of your Config folder where it will create your new sessions by default. The location it finds in the registry should usually correspond to the Configuration Folder path you see in the General category of the Global Options dialog. When this script is launched, it will prompt you for the folder in which you would like to store imported .ini files, defaulting to the current location of your configuration folder as indicated in the global options. If you launch SecureCRT with a shortcut that uses the /F command-line argument to specify a different location for the configuration folder, you’ll need to enter this special configuration folder location manually rather than trust in the default value that is read in from the registry. Running the scriptOnce you have made the necessary configuration changes to your data file and/or the script, you can launch the script by double-clicking on the script filename in Windows Explorer. You will be prompted to specify the location of the host data file to be imported:
Once you have specified your data file, you should see the following pop-up message, which allows you to confirm or change the location of your Config folder. We suggest that when testing (to ensure that the script does what you desire), you specify a temporary folder as the destination folder so that imported session .ini files can be inspected and reviewed after the script has run its course – without affecting your current configuration.
Once the destination path has been specified and the OK button has been pressed, the script will attempt to create sessions using the data provided in the file. After the work has been completed, the script will write information to a log file stored within the specified configuration folder and then launch the file with your computer's default .txt file handler.
Notice that since lines 4, 7, and 10 of our example data file presented earlier were blank, the report indicates that sessions were not created for the data contained on those lines. After the script has completed, you can open the SecureCRT application and view the Connect dialog to see the sessions that have been created.
Here is the sample VBScript code for the import script in its entirety. (Note: for this script to work properly, you should save the file with a .vbs extension):
|
|||||||||||||||||||||||||
| Products | Downloads | Purchase | Support | About Us | |
|---|---|---|---|---|---|
| VShell Server | VShell Server | Buy Direct | Evaluation | Contact | |
| SecureCRT | SecureCRT | License Pricing | Updates Policy | Press Releases | |
| SecureFX | SecureFX | About Encryption Export | FAQs | What's New | |
| VanDyke ClientPack | VanDyke ClientPack | Orders FAQ | Tips & How-Tos | Customer Stories | |
| Beta Software | Beta Software | Resellers | Forums | Secure Solutions | |
|
Site Map | Legal Notices | Privacy Policy | Refund Policy VShell, SecureCRT, SecureFX, Entunnel, CRT, and AbsoluteFTP are trademarks or registered trademarks of VanDyke Software, Inc. in the United States and/or other countries. All other trademarks or registered trademarks are the property of their respective owners. Copyright © 1995 - VanDyke Software, Inc. All rights reserved. |
|||||