執行reboot命令通過SSH我使用Paramiko建立一些目標設備的SSH連接,我想執行reboot
命令。使用的paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(zip_hostname, username=username, password=password, timeout=1)
try:
stdin, stdout, stderr = ssh.exec_command("/sbin/reboot -f")
# .........
# some code
# .........
except AuthenticationException, e:
print ''
finally:
ssh.close()
但在執行ssh.exec_command("/sbin/reboot -f")
後「一些代碼」不執行,因爲程序是停留在exec_command
(斷線發生造成重新啓動的地方)。我該怎麼做才能解決我的問題?