【发布时间】:2020-08-19 21:50:06
【问题描述】:
我正在尝试通过 paramiko 获取广播消息,以确保操作已完全执行。像这样。
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, 22, user, passwd, timeout=180)
command = 'sleep 3; wall "The system will shutdown in 3 seconds."; sudo nohup shutdown -h now;'
stdin, stdout, stderr = ssh.exec_command(command, timeout=300)
if "The system will shutdown in 3 seconds." in stdout.read().encode('utf-8'):
print "Command success!!"
else
print "Command failure!!"
但是,我总是得到一个空输出。如何获得输出?
【问题讨论】:
标签: python linux shell ssh paramiko