Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting

Thread Tools Rate Thread Display Modes
Old 01-29-2013, 07:01 AM
drockney drockney is offline
Registered User
Join Date: Aug 2008
Posts: 2
ConnectInTab using Python

Apologies if this has been asked before, but a cursory search of the repository didn't find an exact match.

I'm attempting to write a script for SecureCRT 7.0.3 that connects to a number of sessions in tabs, running a command on each as it goes. I can get the command-line version working (e.g. SecureCRT /T /S STAGE/server001 /N "first"), but would really prefer to have this as a Python script I invoke within SecureCRT. (I use Linux and Windows workstations.)

I have this code (cut to bare bones):
def Main():
        Set objTab1 = crt.Session.ConnectInTab("/s STAGE/server001") 
        Set objTab2 = crt.Session.ConnectInTab("/s STAGE/server002") 

It throws the following error:
Error: invalid syntax
File: H:\SecureCRT\ConnectInTab.py
(e.g. the first attempt to connect in a tab)

The (seemingly-equivalent) VBS is working fine:
Set objNewTab = crt.Session.ConnectInTab( "/s STAGE/server001")
Am I doing something wrong? Or is this Python's way of telling me that the ConnectInTab functionality isn't supported?
Reply With Quote
Old 01-29-2013, 07:58 AM
rtb rtb is offline
VanDyke Technical Support
Join Date: Aug 2008
Posts: 4,306
Hi drockney,

Thanks for the question. Syntax errors just mean that the code you have written is not understandable by the interpreter.

In your case, the code you are using is VBScript specific, and Python doesn't understand the Set keyword that VBScript uses to get a handle to an object.

You may want to reference the Scripting / Script Objects Reference chapter of the help files for Python specific syntax as it will vary from VBScript syntax, but all SecureCRT methods, properties and objects should be supported in either scripting language.

Here is the code you would use in Python:
def Main():
    objTab1 = crt.Session.ConnectInTab("/s STAGE/server001") 
    objTab2 = crt.Session.ConnectInTab("/s STAGE/server002") 

Does this help to resolve the issue?

VanDyke Software
Technical Support
Reply With Quote
Old 01-29-2013, 08:42 AM
drockney drockney is offline
Registered User
Join Date: Aug 2008
Posts: 2
Yes it does. I found my error a few minutes after originally posting this. Too many different scripting environments - should've noticed it was invalid Python syntax. Sorry for the trouble, thanks for the quick reply!
Reply With Quote

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 11:27 AM.