简体   繁体   中英

Need to run SecureCRT session from the CMD

Sorry for any issues but this is my first post here and thank you in advance for your any comments.

I need to run following command from the CMD: C:\Users\Name\Documents\CRT\SecureCRT.EXE /S \DEVICES\device where device will be added in the loop from the list.

I got following:

for p in devices:
    subprocess.Popen([r'C:\Users\Name\Documents\CRT\SecureCRT.EXE /S'] + devices)

I got follwing error: Traceback (most recent call last): File "C:\Users\Name\Documents\TICKETS\2020\July 2020\Change start stop2.py", line 89, in <module> subprocess.Popen([r'C:\Users\Name\Documents\CRT\SecureCRT.EXE /S'] + devices) File "C:\Users\Name\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "C:\Users\Name\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 997, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified

I think you have to use this subprocess.Popen([r'C:\Users\Name\Documents\CRT\SecureCRT.EXE /S'] + devices)

Use // insted of /

This command fix the issue.

for p in devices:
subprocess.Popen([r'C:\Users\Name\Documents\CRT\SecureCRT.EXE', '/T', '/S', '\\DEVICES\\CORE\\' + p])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM