VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   [Python] Renam tab in a script (https://forums.vandyke.com/showthread.php?t=13176)

cguillaume 07-16-2018 08:48 AM

[Python] Renam tab in a script
 
Hello,

is it possible to rename a tab inside a script ?
I created a script which open many tab (on for each of my switches) by taking an input file containing a list of IP addresses.

Code:

cmd = "/SSH2 /L %s /PASSWORD %s /C AES-128-CTR,AES-128 /M SHA1 %s" % (user, passwd, ip_address)
                crt.Session.ConnectInTab(cmd)

each tab has the ip_addr as name. Is it possible to modify it in the script ?

best regards

ekoranyi 07-16-2018 09:10 AM

Hi cguillaume,

It is possible to rename tabs from within a script. This is done with the Caption property of the Tab object. I've included a brief example below.

Code:

# $language = "Python"
# $interface = "1.0"

objTab = crt.GetScriptTab()
objTab.Caption = "This is the new tab name"

For further information on the available Properties/Methods please review the scripting information available in SecureCRT's help file. While in the Contents tab choose Scripting then Script Objects Reference.

Does this help get you the functionality you're looking for?

cguillaume 07-16-2018 09:15 AM

It is exactly that
thank you

cguillaume 07-16-2018 09:45 AM

I have another question linked to this subject.

Is it possible to get the active tab name in a script, in order to be sure that a specific script is executed from the right tab ?

ekoranyi 07-16-2018 09:58 AM

cguillaume,

It is, you would use the same Caption property.

Code:

objTab = crt.GetScriptTab()
strTabName = objTab.Caption

crt.Dialog.MessageBox(strTabName)



All times are GMT -6. The time now is 10:06 PM.