我有来自here的以下代码,几乎没有修改:#!/usr/bin/env python
import paramiko
import select
server = "192.168.100.100"
port = 22
name = "root"
password = "pass"
def main():
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.MissingHostKeyPolicy())
client.connect(server, port, name, password)
channel = client.get_transport().open_session()
channel.exec_command("/tmp/test.sh")
while True:
if channel.exit_status_ready():
break
r, w, x = select.select([channel], [], [], 0.0)
if len(r) > 0:
print channel.recv(1024)
if __name__ == "__main__":
main()
在哪里测试.sh包括以下内容:
^{pr2}$
所以在执行python脚本之后,每个脚本的CPU使用率将达到100%。这意味着这个select函数不会等到一个或多个文件描述符准备好进行某种类型的I/O。。。循环'将连续迭代,即使没有显示要读取的数据。如何使远程输出异步读取?在