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 01-25-2017, 12:07 AM
ratneshnagori ratneshnagori is offline
Registered User
 
Join Date: Jan 2017
Posts: 1
Script to open multiple tabs & connect

Hi

Can someone please help with script for below requirement :-

I want to open multiple SSH sessions in tabs.

1. Open a tab
2. SSH to predefined server with provided username/password.
3. Repeat 1-2 for multiple times.

Is it possible in SecureCRT?

Appreciate your response.

Thanks
Reply With Quote
  #2  
Old 01-25-2017, 11:27 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 974
What do you mean by "predefined server"?
Is this a saved session already in SecureCRT's session manager?


What do you mean by "provided username/password"?
Do you want to be prompted for these as part of the script?


When you "repeat 1-2 for multiple times", what does this mean? Always the same server? Always the same user/password combination?

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
  #3  
Old 03-07-2017, 03:28 PM
Adlerjay Adlerjay is offline
Registered User
 
Join Date: Mar 2017
Posts: 3
script to open multiple tabs & connect

Jake,
I have a similar question for the sessions defined in the connection tree, I would like to open all the sessions (using a script) and execute a script a startup script. I understand how to auto start a script for an individual session, though I don't know how to start all the sessions that are in the folder. Let me know if this makes sense.
Reply With Quote
  #4  
Old 03-07-2017, 03:44 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi Adlerjay,

I just want to clarify:

It sounds like you are familiar with using Options > Session Options > Logon Actions to have a Logon Script applied to a session. This would allow a script to be automatically run when a session is started.

You now are looking for a way to have a script automatically start every session.

Does that sound right?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 03-08-2017, 01:16 PM
Adlerjay Adlerjay is offline
Registered User
 
Join Date: Mar 2017
Posts: 3
Script to open multiple tabs & connect

Yes I want to be able to open multiple sessions in my folders. I probably have some that I want to exclude.
Reply With Quote
  #6  
Old 03-08-2017, 02:46 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi Adleryjay,

Do you specifically want to launch them with a script?

One easy way is to select sessions from the Session Manager using the Shift and Ctrl buttons, they use the standard selection rules.

CTRL – allows you to click and select multiple files that are anywhere on your file list, not necessarily next to each other.

Shift – allows you to select a group of files that are contiguous (i.e. next to each other) by clicking one file, and then holding Shift and clicking the last file. All the files in between are then selected.

After you select the sessions you would like to open you can either right click on one and choose Connect in Tabs or use the shortcut Alt-B

You can also place all the sessions you want to launch into a folder and use Connect in Tabs on the folder to launch all included sessions.

Does this information help?
__________________
Thanks,
--Eric

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

Last edited by bgagnon; 03-08-2017 at 02:51 PM.
Reply With Quote
  #7  
Old 03-09-2017, 02:10 PM
Adlerjay Adlerjay is offline
Registered User
 
Join Date: Mar 2017
Posts: 3
that is fine, but how can I write a script that would do the same thing?
Reply With Quote
  #8  
Old 03-09-2017, 02:42 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hello Adlerjay,

At the command line it looks like:

<path to install folder>\SecureCRT.exe /S Session1 /S session2 /S Session_3

Just repeat the /S <session name> for all sessions.

In a script this same thing can be done. the line in the script would be very similar to the command line. For example:

crt.session.Connect("/S Session1 /S session2 /S Session_3")

It would look something like:

Code:
## $language = "VBScript"
# $interface = "1.0"

Sub Main()

crt.Session.ConnectInTab("/S session1 /S session2 /S session3")

End Sub
You can also use:

Code:
crt.Session.Connect("/session_folder foldername")
This will launch all sessions contained in a folder

Code:
crt.Session.Connect("/session_folder \")
Will launch every session.


Does this help?
__________________
Thanks,
--Eric

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

Last edited by ekoranyi; 03-09-2017 at 02:51 PM.
Reply With Quote
  #9  
Old 06-16-2017, 03:09 PM
rzavala rzavala is offline
Registered User
 
Join Date: Jun 2017
Posts: 6
Post

Quote:
Originally Posted by ekoranyi View Post
Hello Adlerjay,

At the command line it looks like:

<path to install folder>\SecureCRT.exe /S Session1 /S session2 /S Session_3

Just repeat the /S <session name> for all sessions.

In a script this same thing can be done. the line in the script would be very similar to the command line. For example:

crt.session.Connect("/S Session1 /S session2 /S Session_3")

It would look something like:

Code:
## $language = "VBScript"
# $interface = "1.0"

Sub Main()

crt.Session.ConnectInTab("/S session1 /S session2 /S session3")

End Sub
You can also use:

Code:
crt.Session.Connect("/session_folder foldername")
This will launch all sessions contained in a folder

Code:
crt.Session.Connect("/session_folder \")
Will launch every session.


Does this help?

Hi Eric,

I'm doing a script, and I was able to open a new tab, but I'm not able to send commands to the new tab, I set 1 line after open the new tab, just for testing, but it goes thru the tab what I was using when I open my script, it doesn't goes to the new tab... is there a way that I can specify that I want those lines on the new tab?

Thanks.
Reply With Quote
  #10  
Old 06-16-2017, 04:42 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi rzavala,

You would first want to use the GetTab method. This does not bring the tab or tiled session window to the foreground. This lets the script know which tab you want to work with. The tabs are numbered according to their order in the tab bar. The syntax is:

Code:
Set object = crt.GetTab(arg)
If all you want to do is send commands to this tab you should not be able to. If you would like to bring the tab to the foreground so you can see it you would want to use the Activate method. The syntax is:

Code:
object.Activate
The below example will open 3 tabs, then use GetTab and Activate to bring the 2nd tab to the foreground and allow commands to be sent to it.

Code:
# $language = "VBScript"
# $interface = "1.0"

Sub Main()

crt.Session.ConnectInTab("/S session1 /S session2 /S session3")

Set objTab = crt.GetTab(2)
objTab.Activate

End Sub
Does this help?
__________________
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 12:46 AM.