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-09-2018, 04:32 PM
awittenb awittenb is offline
Registered User
 
Join Date: Sep 2017
Posts: 9
Create tab group in script?

I have a logon script that opens a bunch of tabs which works fine. I would like to be able to send some of those tabs to a new tab group once I'm logged in. Is it possible to create a tab group from a script? I don't see anything in the reference for this.
Reply With Quote
  #2  
Old 01-09-2018, 05:34 PM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 435
There is not currently any scripting API for managing tab groups nor moving tabs from one tab group to another.

I've added a feature request for you.

Depending on how complex you need things to be, you can effectively get new sessions opened in a tab group using this method:
  1. Connect to all sessions you desire to exist in left-most tab group first.

  2. Connect to the first session of your new tab group. After connection is successful, use the following statement to send the active tab (the most recent connected) to a new tab group:
    crt.Screen.SendSpecial("MENU_TAB_SEND_TO_NEW_TAB_GROUP")

  3. Any ConnectInTab calls you make from here on will open tabs in the new tab group.

Here's an example:
Code:
# $language = "VBScript"
# $interface = "1.0"

crt.Session.Connect("/S ""Session 1""")
crt.Sleep(1000)
crt.Session.ConnectInTab("/S ""Session 2""")
crt.Sleep(1200)
crt.Session.ConnectInTab("/S ""Session 3""")
crt.Sleep(1000)

' Connect to first session desired for new tab group:
crt.Session.ConnectInTab("/S ""Session 4""")
crt.Sleep(1500)
' Send that tab to a new group
crt.Screen.SendSpecial("MENU_TAB_SEND_TO_NEW_TAB_GROUP")
crt.Sleep(1200)

' From here on out, any new connections in tabs will appear
' in the new tab group:
crt.Session.ConnectInTab("/S ""Session 5""")
crt.Sleep(1200)
crt.Session.ConnectInTab("/S ""Session 6""")
crt.Sleep(1200)

' Activate all the existing tabs one by one, and
' rename them:
For i = 1 to crt.GetTabCount
    crt.GetTab(i).Activate
    crt.GetTab(i).Caption = "Tab " & i
    crt.Sleep(500)
Next
__________________
Thanks,
--Brittney

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

Last edited by jdev; 01-09-2018 at 05:43 PM.
Reply With Quote
  #3  
Old 01-09-2018, 06:57 PM
awittenb awittenb is offline
Registered User
 
Join Date: Sep 2017
Posts: 9
Thanks so much. This worked perfectly.

Python code I'm using in case anyone else finds it useful:

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

SERVERS = [
    ('s1', 's1.example.com', False),
    ('s2', 's2.example.com', False),
    ('s3', 's3.example.com', True),
    ('s4', 's4.example.com', False),
]

def Main():
    for (caption, server, new_tab_group) in SERVERS:
        tab = crt.Session.ConnectInTab('/s jumpserver', True)
        tab.Caption = caption
        tab.Screen.WaitForString('> ')
        tab.Screen.Send('ssh %s\r' % server)

        if new_tab_group:
            tab.Screen.SendSpecial("MENU_TAB_SEND_TO_NEW_TAB_GROUP")

Main()
Reply With Quote
  #4  
Old 01-10-2018, 09:32 AM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 435
You are very welcome! I am happy to hear that it worked well for you!

Thanks for sharing!
__________________
Thanks,
--Brittney

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

Last edited by berdmann; 01-10-2018 at 09:33 AM. Reason: Typo
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 07:24 AM.