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 03-25-2019, 10:37 AM
Reno Reno is offline
Registered User
 
Join Date: Mar 2019
Posts: 25
Check if CRT tab is open before switching to it

I have a list of my US Ubuntu VM's setup in an array and then I'm looping through those connections, opening them and doing a (just a sample) 'ls -lrt' in each after opening them. Example below is just opening the first VM from the array (I eliminated the loop from the example).

After Macro #1 is run, I need to look at each tab, checking something. I might need to close some connections if something isn't right, before proceeding.

At this point, I need to run another macro to select each tab that's still open and perform some actions.

Question: In SecureCRT VBscript, how to I loop through all the open tabs and get an array of the tab names? I'm having difficulty finding out how to loop through each OPEN tab and collect it's tab name. Thank you!

Also: While I'm here, the main "Scripting Essentials.pdf" file to reference is from 2010? Have there really been no improvements in almost 10 years? Mostly I'm thinking of needing forms in the future and the really akward way of only being able to make forms in HTML and using (external) IE.




Dim ubuntu_crt_connections(10)
ubuntu_crt_connections(0) = "ubuntu\akr"
ubuntu_crt_connections(1) = "ubuntu\aln"
ubuntu_crt_connections(2) = "ubuntu\alp"
ubuntu_crt_connections(3) = "ubuntu\art"
ubuntu_crt_connections(4) = "ubuntu\bth"
ubuntu_crt_connections(5) = "ubuntu\chc"
ubuntu_crt_connections(6) = "ubuntu\cnc"
ubuntu_crt_connections(7) = "ubuntu\gsv"
ubuntu_crt_connections(8) = "ubuntu\hst"
ubuntu_crt_connections(9) = "ubuntu\nyc"
ubuntu_crt_connections(10) = "ubuntu\vnn"

Code:
LOOP - Like FOR x = 0 to ubound(ubuntu_crt_connections) -2		
Set ubuntu_1 = crt.Session.ConnectInTab("/S """ & ubuntu_crt_connections(0) & """") 
ubuntu_1.Screen.Synchronous = True
ubuntu_1.Screen.WaitForString chr(126) & "]$ "
LOOP - NEXT
Reply With Quote
  #2  
Old 03-25-2019, 01:06 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,997
Hi Reno,

What version of SecureCRT are you using?

Here's a code snippet showing how to iterate through tabs, adding the captions to an array.
Code:
    Dim vTabs(10)
    For i = 1 To crt.GetTabCount
        Set objTab = crt.GetTab(i)
        vTabs(i) = objTab.Caption
    Next
Quote:
Also: While I'm here, the main "Scripting Essentials.pdf" file to reference is from 2010? Have there really been no improvements in almost 10 years?
What improvements are you looking for? Different script examples? You can find those in this forum post.

VBScript has not really changed in 10 years. The manual mostly illustrates concepts in SecureCRT that have not really changed since 2010 either. When I compare the list of Objects available in Scripting / Script Objects Reference Help topic (from the screenshot on page 3), the only new object in version 8.5.3, the current, official release is CommandWindow.

If a new object, method or property is added to SecureCRT, that info can be found in the History file that is updated with each release of SecureCRT. Such as:

Changes in SecureCRT 7.2 (Beta 1) -- October 8, 2013
----------------------------------------------------
New features:

  • Added a script object CommandWindow that provides access to the command (chat) window from a script.
  • The script function Screen.Send() can be used to send text to the screen only by using a new optional parameter.
However, it's incremental. In other words, to see changes from v7.2 to v7.3, you have to look at v7.3's History file. To see changes from v8.0 to v8.1, view v8.1's History file, etc.

Quote:
Mostly I'm thinking of needing forms in the future and the really akward way of only being able to make forms in HTML and using (external) IE.
So, this is a feature request for forms scripting? That is still a feature request.

I have added this thread to a feature request in our product enhancement database for the ability to create custom dialog boxes or other GUI elements (forms scripting). Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include "Feature Request - Forum Thread #13468" in the subject line or use this form from the support page of our website.

As far as finding/sharing new ways to use IE as a "go-between", we do have more examples than appears in the scripting manual. That's sort of above and beyond the scope of normal SecureCRT support since our app is usually only peripherally involved. What sort of better (non-awkward) incorporation with IE are you looking for?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 03-26-2019, 03:10 PM
Reno Reno is offline
Registered User
 
Join Date: Mar 2019
Posts: 25
Thanks for the information.

Mostly, when first learning up on CRT scripts, I was a bit sad to see the only possibility for forms comes from using HTML for IE. On my laptop, calling a web form with IE results in IE opening minimized and flashing. I have used VBA forms in the past and wasn't prepared for VBscript not having real form controls like VB or VBA. I'll get use to it.

I had thought about trying to see if I could get TKinter working with Python. But, I abandoned the thought of using Python for scripting after I noticed VBscript is the default choice when recording (unless manually changing the file extension). Also, the majority of examples and reference material appear to be VBscript slanted. It seemed better to just go with VBscript since it's the default recording option and more information is available for it.
Reply With Quote
  #4  
Old 03-26-2019, 03:23 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,997
Hi Reno,

We are trying to convert our script examples to Python and also produce a Python scripting manual but it all comes down to available resources.

I think customers have reported mixed results with Tkinter (but it is not supported on Windows presently).

I have added this thread to a feature request in our product enhancement database to add support for Python GUI APIs/modules like wxPython, pygtk and pyqt. Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include "Feature Request - Forum Thread #13468" in the subject line or use this form from the support page of our website.
__________________
Thanks,
--Brenda

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

Last edited by bgagnon; 03-26-2019 at 03:50 PM. Reason: clarification
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 03:44 AM.