How to run tmsh(F5) command using python SSH Paramiko

1.2k views Asked by At

How can I run tmsh (f5) command and get output using 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') // ??? 
1

There are 1 answers

1
Suruchi Srivastava On

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. Without grep it will return blank output in stdout.read().