Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-11-2019, 04:57 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,099
Post Example: Iterate Over Saved Sessions

These example scripts demonstrate how to iterate over saved sessions in SecureCRT's configuration folder's Sessions subfolder.

There isn't yet a native scripting API provided by SecureCRT for accessing saved sessions (say, from the Session Manager), so the way to go about this is to iterate over the .ini files in the Sessions subfolder of SecureCRT's configuration folder, and use the full file system path information to build up a session manager path (as it appears in the Session Manager) so that you can load the configuration using the crt.OpenSessionConfiguration(strSessionMgrPath) method to get a reference to the Config object for a specified session.

These two iteration examples demonstrate not only how to iterate over all saved sessions (ignoring the Default.ini and the informational __FolderData__.ini files) but also how to export saved session data to CSV file or conf/INI file format.

Script: IterateOverAllSessionsRecursively_CSVOutputFormat.vbs.txt
Script: IterateOverAllSessionsRecursively_ConfFileOutputFormat.vbs.txt

EDIT: (22 Apr, 2020)
Added a python example (IterateOverAllSessionsRecursively_changeOptionValue.py.txt) which iterates over saved sessions, changing the host name.

EDIT: (11 Aug, 2020)
Added another python example (ChangeHostnameAndPortForAllSessions.py.txt) which changes (for all saved sessions) both the host name and the port to argument values specified.
For example: SecureCRT.exe /SCRIPT ChangeHostnameAndPortForAllSessions.py.txt /ARG hostname:192.168.232.220 /ARG port:33222 /ARG "exclude:session1|session 2|Session #3"

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support

Last edited by jdev; 08-11-2020 at 01:21 PM.
Closed Thread

Tags
example script

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 12:16 AM.