0

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 Answers1

0

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().

  • Not sure how this help. But if it really helps, then using `cat` instead of `grep ''` would be a more straightforward solution. – Martin Prikryl May 21 '20 at 06:00