我有一些ssh的输出。我想用python使它整洁
ip_address = "xxxx"
username = "xxx"
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname=ip_address,username=username)
remote_connection = ssh_client.invoke_shell()
remote_connection.send("show run | i _20.20.20.20\n")
time.sleep(5)
readoutput = remote_connection.recv(65000)
ssh_client.close()
print(readoutput)
现在我得到:
RouterA#show run | i _20.20.20.20
neighbor 20.20.20.20 remote-as 202025
neighbor 20.20.20.20 password password
neighbor 20.20.20.20 activate
crs1.ams1#
也在Html我得到这个
b'\r\nRouterA#show run | i _10.10.10.10\r\n neighbor 10.10.10.10 remote-as 1010\r\n neighbor 10.10.10.10 password password1010\r\n neighbor 10.10.10.10 activate
我想要的是:(输出中没有\n)
""""
RouterA#show run | i _20.20.20.20
neighbor 20.20.20.20 remote-as 202025
neighbor 20.20.20.20 password password
neighbor 20.20.20.20 activate
RouterA#
"""
关于:
对于html输出,它是bytestring:
输出:
相关问题 更多 >
编程相关推荐