I was able to create a test.py application/process that uses pexpect with /exos/bin/ssh similarly to your script and I used a UPM profile and timer to restart it every 5 minutes. It worked.
Here is the UPM configuration:
## Module upm configuration.
#
create upm profile test
disable cli prompt
restart process test
.
create upm timer test
configure upm timer test profile test
configure upm timer test after 1 every 300
...
And here is the py file for the process and the command to create it. (I assumed that the ssh targets were sub-tended EXOS switches and so I sent the "disable cli prompting" command to avoid unnecessary pexpect lines in the process script.)
#vi test.py
import pexpectimport exos.api
def exosCmd(cmd):
reply = exos.api.exec_cli([str(cmd)], ignore_errors=True)
return str(reply)
def logMsg(m):
exosCmd('create log message "{0}"'.format(m))
logMsg("Starting NSCBackup!")
p = pexpect.spawn('/exos/bin/ssh -r 2
[email protected]')
idx = p.expect(['password', pexpect.EOF, pexpect.TIMEOUT])
p.sendline('admin')
idx = p.expect(['x202', pexpect.EOF, pexpect.TIMEOUT])
p.sendline('create log message "test test test"')
idx = p.expect(['x202', pexpect.EOF, pexpect.TIMEOUT])
p.sendline('disable cli prompt')
idx = p.expect(['x202', pexpect.EOF, pexpect.TIMEOUT])
p.sendline('save')
idx = p.expect(['x202', pexpect.EOF, pexpect.TIMEOUT])
p.sendline('exit')
#^wq!
...
The process was started with this line that I issued before starting the UPM timer:
create process test py test start auto
...
Hope this helps.