View Single Post
  #4  
Old 04-06-2021, 01:30 PM
cboyack cboyack is offline
VanDyke Technical Support
 
Join Date: Apr 2020
Location: Albuquerque, NM
Posts: 129
Hi again Chris,

In all honesty, it seems like a miracle that the scripts worked as nicely as they did for you with the older version of SecureCRT, as the current working directory can mean a lot of different things, and it just happened to land nicely for you in the past. Take the following script, for example:
Code:
# $language = "Python"
# $interface = "1.0"

import os
strDir1 = os.getcwd()
strDir2 = os.path.dirname(os.path.realpath("."))
strDir3 = os.path.dirname(os.path.realpath(__file__))
strDir4 = os.path.dirname(crt.ScriptFullName)
crt.Dialog.MessageBox("dir1: {}\ndir2: {}\ndir3: {}\ndir4: {}".format(
    strDir1,
    strDir2,
    strDir3,
    strDir4))
If you run this script, you can see how, depending on the context, different versions of the current working directory can result in a file being written/opened in wildly different locations. If you're simply looking to have the file be written within the same directory in which the .py file was run, please consider using the format from line 7 or 8 from the above script to obtain that directory for further use in your script.

If you're looking for some other behavior in which the script will open/write to a file in some other location, what's the anchor for that location?
__________________
Thanks,
--Cameron

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