I am having trouble receiving the complete output of a command run from a Python script with paramiko using SSH to connect to the router.
When I run 'ip firewall connection print' in the terminal on the router GUI it prints the whole connections table along with all the columns with data rates and whatnot.
When I run the same command from the python script, it manages to connect and print the output but only part of it. The last column is TCP-STATE and the rest does not get printed out.
I think I know what the catch is. When I run the command from a Putty terminal while it is not fullscreen it does the same thing - prints only part of the table. When I fullscreen it, it prints out the whole table. So I presume the terminal window (which is of course invisible to me) that the script opens is not big enough to hold all of the columns so only part of it gets printed out.
Here is the script :
Code: Select all
import paramiko
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('myDefaultGateway', username='myUsername', password='myPassword')
stdin, stdout, stderr = client.exec_command('ip firewall connection print')
for line in stdout:
print(line.strip('\n'))
client.close()