VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   call script.py (https://forums.vandyke.com/showthread.php?t=14044)

Neisany 01-17-2020 02:57 AM

call script.py
 
is there any esay way to call a python script into the script thats running

file 1
main.py
Code:

# $language = "python"
# $interface = "1.0"

crt.Screen.Synchronous = True

main():

  import os
  strHome = os.path.expanduser('~')
  strPathToFile = "{0}/Documents/test1.py".format(strHome)
  strPathToFile = strPathToFile.replace('\\','/')
 

  run(strPathToFile)  <-- this is where I need help

I am looking to call different files to make the script modular and update-able easily. The second reason is some parts of the script will run independently of the main sub and will not want to use the main.

second file
test1.py
Code:


# $language = "python"
# $interface = "1.0"

crt.Screen.Synchronous = True

def main():
        crt.Dialog.MessageBox("hello world")

main()


bgagnon 01-17-2020 08:14 AM

Hi Neisany,

It's more a Python question than a SecureCRT question, but when I googled it, the answer was to use import. I hope this helps.


All times are GMT -6. The time now is 02:30 AM.