Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-29-2018, 02:31 PM
paul- paul- is offline
Registered User
 
Join Date: Aug 2018
Posts: 2
Reference a saved session

Hello,

Is it possible to reference/connect to a session(s) that has been saved in the 'Sessions' folder/subfolders?

In my script, I'm wanting to take a users input for a folder and connect to the devices in the selected folder.

-Thanks
Reply With Quote
  #2  
Old 08-29-2018, 03:21 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 526
Hi paul-,

It is possible to connect to a saved session using the Connect method. The Connect method takes a string parameter that specifies how a connection is to be made. The format of the string parameter matches the format of the command line arguments to SecureCRT.

The format for specifying a saved session is:
Code:
/S session_name
Starts SecureCRT and opens a connection A data path or circuit between two computers over a phone line, network cable, or other means. with session_name. If session_name includes any spaces, it must be enclosed with quotation marks, (e.g., "My Session").
This may look something like:
Code:
crt.session.Connect("/s folder/mysession")
Your use case of connecting to every session in a folder may be a bit more difficult. You would most likely need to recursively iterate over the folder and capture all the session names, then connect to each. Can you help me better understand your use case and why you would like your users to specify a folder and connect to each session by script? Would simply right clicking on a folder in the Session Manager and choosing Connect In Tabs be an option?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 08-29-2018, 03:37 PM
paul- paul- is offline
Registered User
 
Join Date: Aug 2018
Posts: 2
Thanks for the reply Eric. The use case is to run a script to connect to a list of devices and then execute commands on those selected devices. In this case, I would be selecting a folder of devices.

I'm specifically thinking to open the sessions from the folders, in order to skip doing authentication via the script and instead use the saved credentials in the saved sessions.

Although, I hadn't thought of opening the sessions first and then running a script against the open tabs. I might look into doing that instead.

Thanks
Reply With Quote
  #4  
Old 08-29-2018, 03:59 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 526
paul-,

If it were me I would definitely approach it from the "other way". Connecting to all the required sessions first in SecureCRT then running your script on each. This seems not only less prone to errors but easier to script by a large margin.

After connecting to all the needed devices I see a couple of different options to run your script. You could write your script to iterate over all open tabs running the needed commands on each. Another, and again easier option, would be to use SecureCRT's Button Bar.

To enable the Button Bar choose View > Button bar. The Button Bar should appear at the bottom of the SecureCRT window. Right clicking on the Button Bar will allow you to create a new button. As the Function choose Run Script. After selecting your script and choosing a Label save your changes.

Now you can simply click the button to run the script in the currently active tab, or even better, hold Shift and click the button to run the script in all tabs.

Using the Button Bar would make the script much easier to write (no recursion or looping through the tabs) and make the process fairly efficient. Right click on a folder in the Session Manager and choose Connect in Tabs then hold Shift and click a button on the Button Bar.
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 08:12 AM.