如何使用python SSH Paramiko运行tmsh(F5)命令

问题描述 投票:0回答:1

如何运行tmsh(f5)命令并使用SSH python获取输出?

    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') // ??? 
python paramiko f5 tmsh
1个回答
0
投票

在进行此操作时,我得到了解决此问题的解决方案:

stdin, stdout, stderr =  ssh.exec_command("tmsh show /sys CPU | cat")

print stdout.read()

使用此命令,我可以获得tmsh输出。如果没有grep,它将在stdout.read()中返回空白输出。

© www.soinside.com 2019 - 2024. All rights reserved.