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 08-11-2015, 11:31 AM
garibaldi0 garibaldi0 is offline
Registered User
 
Join Date: May 2010
Posts: 5
Config or Session Path variable for Python

Greetings all:

I'm working on a script where I need to know the file path to the sessions folder on the file system. Is there a variable in Python or the crt module that can be used to find this file path? Something like crt.session.path()?

Thanks!
Reply With Quote
  #2  
Old 08-11-2015, 12:19 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi garibaldi0,

The scripting API doesn't currently offer a method for getting at the configuration folder location.

Would you tell me more about the problem you are trying to solve by finding the path to the configuration folder?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #3  
Old 08-20-2015, 06:54 AM
ogun ogun is offline
Registered User
 
Join Date: Sep 2013
Posts: 15
I have the same problem.

In my case I am creating sessions from a downloaded CSV file that is auto generated from our IPAM. The reason I need the full path of the sessions folder is to do house cleaning on removed sessions etc.

My current workaround is
Code:
    # Remove existing folder, we rebuild every time.
    script_name = crt.ScriptFullName
    script_dir = os.path.dirname(script_name)

    # We expect to be in $CONFIG/Scripts with the sessions in $CONFIG/Sessions
    sessions_folder = os.path.join(script_dir, '../Sessions')

    # Did we get it right?
    if not os.path.isdir(sessions_folder):
        msg = "Could not find sessions folder. Got %s" % sessions_folder
        crt.Dialog.MessageBox(msg)
        return
which works but is a bit of a hack. Depends on specific location of the script itself etc. Being able to just get the session folder with an API call would be nice.

Additionally, could I please have the socket module in python so I can use httplib?
Reply With Quote
  #4  
Old 08-20-2015, 11:00 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,474
Hi Ogun,

Thanks for sharing your workaround.

I have added this thread to a feature request in our product enhancement database to add a Sessions object to scripting API for iterating over all sessions. Should a future release of SecureCRT include this feature, notification will be posted here.


Quote:
Additionally, could I please have the socket module in python so I can use httplib?
I am not sure what you mean by "could I please have", but per this post, it's also a feature request.

I have also added this thread to the feature request in our product enhancement database to add native support for _socket Python module. Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification regarding either feature request, contact support@vandyke.com and include "Feature Request - Forum Thread #12068" in the subject line.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 08-20-2015, 12:15 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,474
Hi all,

I've attached an example Python script that illustrates how to get the path to the config folder (as long as /F isn't specified on the command line).
Attached Files
File Type: txt ConfigFolder-GetPathToConfigFolder.py.txt (3.3 KB, 285 views)
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #6  
Old 09-29-2020, 12:15 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,474
Hi all,

I wanted to let you know the __socket module should be available as of SecureCRT v9.0, currently in beta 1 release, since this support was added:

Changes in SecureCRT 9.0 (Beta 1) -- September 24, 2020
-------------------------------------------------------
New Features:

  • Windows: Added support for Python 3. Python 3.8(available at python.org) must be installed and the script's first line must be: # $language = "python3". Since support for Python 3 is provided through an external module, Python 3 libraries can be used in SecureCRT scripts.

Note that this is Windows only support at this time. In fact, we released beta 1 installers *only* for Windows. We hope to include all platforms in later releases.
__________________
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 07:00 AM.