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 02-14-2017, 01:57 PM
dgoudie dgoudie is offline
Registered User
 
Join Date: Jan 2017
Posts: 6
Python Activate/Close Session

Hi,

I'm wondering if anyone knows the Python equivalent of "tabobj.Activate" and "tabobj.Close".

I'm having no issue opening new tabs and running sessions, but I'd like my script to run on the newly opened tab once it has been opened.

Thanks!
Reply With Quote
  #2  
Old 02-14-2017, 02:12 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,140
Hi dgoudie,

Can you provide some context for your inquiry?

Where did you find those references?

All objects, properties and methods available in SecureCRT are documented in the Scripting / Script Objects Reference topic in SecureCRT's Help file.

There is little difference between the syntax of these methods in VBScript or Python, just the addition of (), which is common in Python:

object.Activate()
object.Close()


The tabobj in your inquiry is likely the tab object that has been created elsewhere in whatever script code you found.
__________________
Thanks,
--Brenda

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

Last edited by bgagnon; 02-14-2017 at 02:16 PM. Reason: Posted early for some reason ... hit some stray hotkey
Reply With Quote
  #3  
Old 02-14-2017, 02:21 PM
dgoudie dgoudie is offline
Registered User
 
Join Date: Jan 2017
Posts: 6
Re

Yes, your assumption is correct, here's my code -

Code:
loop x times:
    tempObj = crt.Session.ConnectInTab("/S \"SessionName\"")
    tempObj.Activate()
    # Execute some commands here in the new tab
    tempObj.Close()
I figured adding parenthesis would be correct, but even after doing so, it seems that the code is still being executed in the original tab that the script is being run in. (If I run this script with no sessions open, all commands run in the first session opened by the first ConnectInTab statement, otherwise they run in the original session that the "Run Script" button was pushed in)

Last edited by jdev; 02-14-2017 at 02:26 PM. Reason: wrap code in [code] blocks
Reply With Quote
  #4  
Old 02-14-2017, 02:47 PM
dgoudie dgoudie is offline
Registered User
 
Join Date: Jan 2017
Posts: 6
Re 2

Okay, I figured out what my problem was. I was using the crt object instead of the one I declared when making the new tab. (tempObj in this case)

Thanks for the help!
Reply With Quote
  #5  
Old 02-14-2017, 03:13 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,140
Hi dgoudie,

Great, thanks for posting the update. I am glad to hear you were able to resolve the issue.
__________________
Thanks,
--Brenda

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 08:35 PM.