脚本有什么问题?它没有用python打印有效的输出

脚本有什么问题?它没有用python打印有效的输出,python,python-2.7,Python,Python 2.7,我正在使用下面的脚本 remote_conn.send("ping 10.10.10.1 vrf us-dc source 10.10.10.249\n") 正在发送作为 ping 10.10.10.1 vrf us-dc source 10.10.10.2$ 我想知道为什么它会在最后发送美元 对于其他IP,它正在正确打印。范例 ping 10.10.10.1 vrf us-dc source 10.10.10.255 我只是在发送前打印的 ping 172.16.34.48 vrf

我正在使用下面的脚本

 remote_conn.send("ping 10.10.10.1 vrf us-dc source 10.10.10.249\n")
正在发送作为

ping 10.10.10.1 vrf us-dc source 10.10.10.2$
我想知道为什么它会在最后发送美元

对于其他IP,它正在正确打印。范例

ping 10.10.10.1 vrf us-dc source 10.10.10.255
我只是在发送前打印的

 ping 172.16.34.48 vrf us-dc source 10.10.10.249 # printed before remote_conn.send so its properly printing.  

when i used with remote_conn.send it is not sending proper output

 ping 172.16.34.32 vrf us-dc source 10.10.10.2$
我不知道我在下面的脚本中做错了什么

出于安全原因,请注意。我没有在这里粘贴实际使用的IP

import paramiko
import re
import time
hostname = "10.10.10.1"
net_username = ""
net_password = ""
remote_conn_pre = paramiko.SSHClient()
remote_conn_pre.set_missing_host_key_policy(
     paramiko.AutoAddPolicy())
remote_conn_pre.connect(hostname, username=net_username, password=net_password,look_for_keys=False, allow_agent=False)
remote_conn = remote_conn_pre.invoke_shell()
buff = ''
while not buff.endswith('#'):
    resp = remote_conn.recv(9999)
    buff += resp
    print(resp)
remote_conn.send("\n")
buff = ''
while not buff.endswith('#'):
    resp = remote_conn.recv(9999)
    buff += resp
    print(resp)
remote_conn.send("ping 10.10.10.1 vrf us-dc source 10.10.10.249\n")
time.sleep(2)
buff = ''
while not buff.endswith('#'):
    resp = remote_conn.recv(9999)
    buff += resp
    print resp
remote_conn.send("ping 10.10.10.10\n")
buff = ''
while not buff.endswith('#'):
    resp = remote_conn.recv(9999)
    buff += resp
    print resp
remote_conn.send("show bgp\n")
buff = ''
while not buff.endswith('#'):
    resp = remote_conn.recv(9999)
    buff += resp
    print resp

保存您试图发送的字符串,并单独打印以查看显示内容。顺便说一下,您可以编写一个函数来接收缓冲区。同一段代码重复了好几次。当然,我需要使用函数,它只是测试elena@elena加上奇怪的问题。您是否看到
远程连接发送(“ping 10.10.10.1 vrf us dc source 10.10.10.249\n”)
呼叫的输出错误?@elena,是的,只有在我呼叫时有问题才奇怪