I am writing a script using python pexpect to execute another script on a remote machine. It works fine in normal cases, but if there is a time.sleep
in the remote script, it fails.
I want to get to the remote machine, start the script in the background and get out. Is this possible ?
Can someone suggest an alternative or开发者_如何学C let me know how to get around this issue?
Have you considered paramiko?
Here's an example ...
#!/usr/bin/env python
import paramiko
ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.connect(hostname='example.com', port=22, username='sethu', password='****')
ssh.exec_command('nohup sleep 300 &')
ssh.close()
精彩评论