[英]How to run tmsh(F5) command using python SSH Paramiko
How can I run tmsh (f5) command and get output using SSH python?如何运行 tmsh (f5) 命令并使用 SSH python 获取 output?
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('1.1.1.1', username='username', password='password')
ssh.exec_command('ls') //Working
# how to execute tmsh command using ssh ?
ssh.exec_command('tmsh show /sys CPU') // ???
While working on this I got the solution to solve this problem:在处理这个问题时,我得到了解决这个问题的解决方案:
stdin, stdout, stderr = ssh.exec_command("tmsh show /sys CPU | cat")
print stdout.read()
Using this command, I can get the tmsh output.使用这个命令,我可以得到 tmsh output。 Without grep it will return blank output in stdout.read().
如果没有 grep,它将在 stdout.read() 中返回空白 output。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.