VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Run multiple scripts to SecureCRT (https://forums.vandyke.com/showthread.php?t=13256)

jeyro 09-22-2018 03:18 AM

Run multiple scripts to SecureCRT
 
Hello,

I have a concept in my mind but I don't know if is it possible or if I think wrong.

I want to execute a python script from my computer. Theses steps :
- Choice (OK)
- Check connectivity (OK)
- Open a new session from secureCRT + send commands to the CLI (OK)
- Execute another independent script to send commands to the CLI (!)

I call my first script with subprocess.popen... but how can I run another script to this active session from my main script ?

Thanks for your reply

bgagnon 09-22-2018 11:19 AM

Hi jeyro,

To the best of my knowledge, there presently is not a way to run one script from another in SecureCRT.

I have added this thread to a feature request in our product enhancement database to add the ability to run multiple scripts in succession (call one script from another). Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include "Feature Request - Forum Thread #13256" in the subject line or use this form from the support page of our website.

Quote:

  1. Choice (OK)
  2. Check connectivity (OK)
  3. Open a new session from secureCRT + send commands to the CLI (OK)
  4. Execute another independent script to send commands to the CLI (!)

The way you wrote the requirements though, to me at least makes it sound like one script handles bullet points 1, 2 and 3. And then another script will accomplish step 4. So if it's a completely independent script, you could just run it from SecureCRT's Script menu, right? It does not need called from another script necessarily ...

Or does it depend on the CLI operations from step 3?

You may find this post/example scripts useful.

jeyro 09-24-2018 06:21 AM

I will try to explain me. I have a main script called DDI_ALL.py. In this one, there is :

Step 2 :
Code:

#Connexion test
ping_serveur = -1
ping_serveur = os.system("ping " + serveur_selected)

Step 3 (DDI_ALL.py calls DDI_connection_cli.py) :
Code:

#Launch SecureCRT
username1=os.getenv('username')
SecureCRTpath = 'C:\\Users\\'+str(username1)+'\\AppData\\Local\\VanDyke Software\\SecureCRT\\SecureCRT.exe'
Scriptpath = 'C:\\Users\\'+str(username1)+'\\Documents\\PROJET\\SCRIPT\\PREPROD\\DDI_connection_cli.py'
print(Scriptpath)

#Connexion CLI
subprocess.Popen(['C:\\Users\\XXXXXX\\AppData\\Local\\VanDyke Software\\SecureCRT\\SecureCRT.exe', '/SCRIPT', 'C:\\Users\\XXXXXX\\Documents\\PROJET\\SCRIPT\\PREPROD\\DDI_connection_cli.py'])

- DDI_connection_cli.py contains :
Code:

cmd = "/SSH2 /L %s /PASSWORD %s /C AES-128-CTR /M SHA2-256 /AUTH password,keyboard-interactive,gssapi %s" % (user, passwd, host)
Step 4 (ex: DDI_ALL.py calls DDI_cmd_check.py): I want to call another script (from DDI_ALL.py) to execute in the active session from SecrueCRT to run others commands like (date, hostname, top, etc...), then log them. I try with the subprocess.Popen but it open a new process :/

Step 5 (ex: DDI_ALL.py calls DDI_parsing_check.py): It will be a parsing from the log file to conclude.

I hope I'm clear (:

bgagnon 09-24-2018 08:12 AM

Hi jeyro,

That scenario falls under the "not possible now, feature request" response. :)


All times are GMT -6. The time now is 11:14 PM.