Executing Commands on linux_ssh

Hi Everyone,

I think the problem is related to netmiko or linux servers but maybe someone can help me here as well:
I tried to use netmiko_send_command with a “linux_ssh” platform and realized that sending long commands fail because of the line break.

    task.run(netmiko_send_command, command_string="hostname")
    cmd = "wget https://raw.githubusercontent.com/nornir-automation/nornir/develop/nornir/plugins/tasks/networking/netmiko_send_command.py"
    task.run(netmiko_send_command, command_string=cmd)

The first “hostname” commands runs fine but the second “wget …” fails.
The Problem ist at “base_connection.py Line 1378” (https://github.com/ktbyers/netmiko/blob/0aaa11066749ee2f75f4082763b7171629b52b4d/netmiko/base_connection.py#L1378)

The command ist too long for the terminal, therefore the result comes back with line breaks

wget https://raw.githubusercontent.com/nornir-automation\rn/nornir/develop/nornir/plugins/tasks/networking/netmiko_send_command.py\r\n--2020-03-07

and that’s why the pattern never matches…

Thanks for your help

I fixed it temporarily by changing the invoke_shell command on base_connection.py line #916:

to self.remote_conn = self.remote_conn_pre.invoke_shell(width=512)

1 Like

This is a Netmiko issue. It should be fixed in a newer version (or your temp fix also works).

1 Like