Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Paramiko recv输出生成所有命令输出,仅期望最后一个命令输出_Python_Paramiko - Fatal编程技术网

Python Paramiko recv输出生成所有命令输出,仅期望最后一个命令输出

Python Paramiko recv输出生成所有命令输出,仅期望最后一个命令输出,python,paramiko,Python,Paramiko,我使用paramiko作为交换机的ssh接口shell 下面是示例代码(请注意完整代码): recv命令打印显示版本输出和显示界面摘要 如何获得变量sp_detail的仅显示界面简短输出 我参考了下面的链接并使用了和他们使用的相同的if语句,但我仍然得到了所有命令的输出 请帮助这就是paramiko(实际上是ssh)的工作原理。你必须过滤掉你不感兴趣的信息。好的,让我过滤一下 remote_conn.send("\n") remote_conn.send("show version") # W

我使用paramiko作为交换机的ssh接口shell

下面是示例代码(请注意完整代码):

recv命令打印显示版本输出和显示界面摘要

如何获得变量sp_detail的仅显示界面简短输出

我参考了下面的链接并使用了和他们使用的相同的if语句,但我仍然得到了所有命令的输出


请帮助

这就是paramiko(实际上是ssh)的工作原理。你必须过滤掉你不感兴趣的信息。好的,让我过滤一下
remote_conn.send("\n")
remote_conn.send("show version")
# Wait for the command to complete
#time.sleep(1)
remote_conn.send("\n")
remote_conn.send("show interface brief")
# Wait for the command to complete
time.sleep(3)
if remote_conn.recv_ready():
    sp_detail = remote_conn.recv(5000)
print(sp_detail)