pythonrobotframeworkparamikorobotframework-sshlibrary

Why Robot Framework's SSHLibrary and Python's Paramiko give different outputs for same command?


In a network device for a script I am building, Robot Framework's SSHLibrary produced the identical result when typing the command manually in the device.

Manual command in Device

But when writing the code with paramiko:

_stdin, _stdout, _stderr = connection.exec_command(f"scm {mac_address}")
output = _stdout.readlines()

It skips the headers for some reason. Shouldn't the output be indentical as apparently SSHLibrary is built on top of paramiko (if AI can be believed)?

Output with Paramiko:

enter image description here

I checked _stderr and it is an empty array ([]).


Solution

  • When you manually ssh to the device and interact with it, the commands are running with a pty. But exec_command() by default would not run commands with a pty. I guess you can fix it like this:

    connection.exec_command(f"scm {mac_address}", get_pty=True)