开发者

Any substitutes for pexpect?

开发者 https://www.devze.com 2023-03-28 02:44 出处:网络
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 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()
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号