#1
|
|||
|
|||
Sessions Directory Variable
Hi Experts,
could you please share a method to derive the active sessions directory path via python script. Clearly I can look up the static path and add it as an entry within my script. But if the path has changed from the defaults, then I need a method to identify its new location. Thanks |
#2
|
|||
|
|||
Hi krypton179,
What version of SecureCRT? See Scripting / Script Objects Reference / Session Object. It is the Path property you will want to use, but as noted, it returns the entire path under the supplied Sessions folder. So you may need to parse the results depending on what data you are trying to get.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
If you are looking for the full file system path, I use the following:
Code:
def get_config_path(): """ Find path of SecureCRTs configuration """ # This could be done using the config variable trick, this one has been proven to work on # many version of SecureCRT. if os.name == "nt": # We're on windows, use the registry import _winreg try: key = _winreg.OpenKey( _winreg.HKEY_CURRENT_USER, "SOFTWARE\\VanDyke\\SecureCRT" ) config_path = _winreg.QueryValueEx(key, "Config Path")[0] _winreg.CloseKey(key) if "%" in config_path: config_path = _winreg.ExpandEnvironmentString(config_path) log.debug("Config path (Win): %s", config_path) return config_path except Exception as e: crt.Dialog.MessageBox(str(e)) elif os.name == "posix": # We're on linux, read the config file try: import ConfigParser config_file = os.path.expanduser("~/.config/VanDyke/SecureCRT.conf") config = ConfigParser.ConfigParser() config.read(config_file) config_path = config.get("General", "Config%20Path") log.debug("Config path (Lin): %s", config_path) return config_path except Exception as e: crt.Dialog.MessageBox(str(e)) else: crt.Dialog.MessageBox("Unknown os") Not tested on versions below 8.0 but I see no reason why it shouldn't work. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|