VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Create tab group in script? (https://forums.vandyke.com/showthread.php?t=12975)

awittenb 01-09-2018 04:32 PM

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.

berdmann 01-09-2018 05:34 PM

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


awittenb 01-09-2018 06:57 PM

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()


berdmann 01-10-2018 09:32 AM

You are very welcome! I am happy to hear that it worked well for you! :)

Thanks for sharing!


All times are GMT -6. The time now is 01:33 PM.