使用 Paramiko 执行的命令不会产生任何输出 [英] Command executed with Paramiko does not produce any output

查看:92
本文介绍了使用 Paramiko 执行的命令不会产生任何输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试去做

stdin, stdout, stderr = client1.exec_command('glass-version')
print stdout.readlines()

我得到一个空输出.

预期的输出是:

===================== GLASS version details =====================
 GLASS version : 1.2.3
=================================================================

推荐答案

如果 stdout 没有输出,通常是因为命令启动失败.

If you get no output on stdout, it is usually because the command fails to start.

阅读 stderr 以检查任何错误.

Read stderr to check for any errors.

print(stderr.readlines())


错误经常是"<command>未找到.见
某些 Unix 命令失败并显示"未找到",当使用 Python Paramiko exec_command 执行时

如果您要连接到设备,另请参阅在设备上使用 Paramiko exec_command 执行命令不起作用.

If you are connecting to a device, see also Executing command using Paramiko exec_command on device is not working.

这篇关于使用 Paramiko 执行的命令不会产生任何输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆