Reputation: 25
I did a script on Windows using PuTTY:
from pywinauto.application import Application
app = Application().Start(cmd_line='C:\Program Files (x86)\PuTTY\putty.exe -l user -pw **pwd** -load Proxy_10.153.1.250 '+ ip +' -ssh')
putty = app.PuTTY
putty.Wait('ready')
time.sleep(7)
cmd1 = "show log "+ "{ENTER}"
This script will be executed for many switchs, but when it is executed, I cannot do other tasks on Windows else script will be interrupted? Is it possible to be executed in background?
Upvotes: 2
Views: 1171
Reputation: 9991
You need a proper tool for CLI automation. Just run subprocess.call('ssh user@host <the rest of cmd>')
or use Paramiko to run remote SSH command.
BTW, pywinauto's code is incomplete, I don't see .type_keys(cmd1)
. You may try .send_chars(cmd1)
instead and use putty.minimize()
first. But send_chars
is not guaranteed to work with every app (and it's experimental). So you can just try.
Upvotes: 2