Hello Python community!
I have problems with simple script which i created for gathering specific data from routers, so I would appreciate your help!
My script should do next:
1. SSH to router and type command "show system licence"
2. Output of that command is in few rows and columns, but I need to take specific part of string and print it out
I stucked at part 2, here is my code:
Original output looks like:
Do you guys have idea how to do that? I am python beginner so be nice to me :)
Best Regards!
I have problems with simple script which i created for gathering specific data from routers, so I would appreciate your help!
My script should do next:
1. SSH to router and type command "show system licence"
2. Output of that command is in few rows and columns, but I need to take specific part of string and print it out
I stucked at part 2, here is my code:
import paramiko,string JUNuser = 'xxx' JUNpass = 'xxx' JUNhost = 'xxx' ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(JUNhost, username=JUNuser, password=JUNpass) stdin, stdout, stderr = ssh.exec_command("show system license") output = stdout.readlines() type(output) final = output[3:4] print '\n'.join(final)With this i managed to get specific row from original output.
Original output looks like:
Output:License usage:
Licenses Licenses Licenses Expiry
Feature name used installed needed
scale-subscriber 0 1000 0 41 days
With part "final = output[3:4]" i managed to get:Output:scale-subscriber 0 1000 0 41 days
What I want to achieve is to tell my script to get only this number of days when licence expire. So I want my script to show me only number 41!Do you guys have idea how to do that? I am python beginner so be nice to me :)
Best Regards!