python - 使用 Paramiko 执行的命令不会产生任何输出

标签 python ssh stdout paramiko

当我尝试做

stdin, stdout, stderr = client1.exec_command('glass-version')
print stdout.readlines()
我得到一个空输出。

预期的输出是:
===================== GLASS version details =====================
 GLASS version : 1.2.3
=================================================================

最佳答案

如果在 stdout 上没有输出,通常是因为命令启动失败。
阅读 stderr检查任何错误。

print(stderr.readlines())

通常错误是“ not found”。为此,请参阅
Some Unix commands fail with "<command> not found", when executed using Python Paramiko exec_command

如果您要连接到设备,另请参阅 Executing command using Paramiko exec_command on device is not working .

关于python - 使用 Paramiko 执行的命令不会产生任何输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70229745/

相关文章:

python - 清理打印命令

java - SSH 命令执行失败并出现异常 - "net.schmizz.sshj.connection.ConnectionException: Connection reset Exception is thrown"

在 C\C++ 中嵌入 Python 时的 Python 打印输出

linux - 这个 Bash(和/或其他 shell?)构造叫什么?

python - Python 中的 Rostopic pub 等效项

Python 扭曲 : read from file and send as TCP server

Python 类继承没有做我认为应该做的事情

ssh - SSH -X 和 ssh -Y 的区别

ssh - 在远程服务器上工作

python - 为什么使用 xargs --max-procs 加扰具有无缓冲输出的 python 进程?