Linux-driver terminal width is not being set by Netmiko
See original GitHub issueHi,
Using Netmiko version 3.0.0 I am trying to connect to a Linux box & then sending a grep command (grep -w {ip}/32 *.set | grep book | grep -v 1b | grep -v 2b) , however, it fails with the below error.
If I remove the pipes ( | ) from the command it works just fine.
Error is pipe related-
raise PipeTimeout() paramiko.buffered_pipe.PipeTimeout
I shouldn’t say its a netmiko error rather some piece of code in the /paramiko/channel.py is complaining. However, if I downgrade the Netmiko to version 2.4.2, this error is never thrown & code finishes without any issues. Paramiko version that I am using is 2.7.1 .
Code:
from netmiko import ConnectHandler
secmt = {'device_type': 'linux','ip': 'secmt03','username': username,'password': '***********' }
secmt_connect = ConnectHandler(**secmt)
grep_op = secmt_connect.send_command_expect(
f'grep -w {ip}/32 *.set | grep book | grep -v 1b | grep -v 2b', expect_string = 'secmt junos-firewall'
)
print(grep_op)
Error:
Traceback (most recent call last): File “/home/satnau/.local/lib/python3.6/site-packages/paramiko/channel.py”, line 699, in recv out = self.in_buffer.read(nbytes, self.timeout) File “/home/satnau/.local/lib/python3.6/site-packages/paramiko/buffered_pipe.py”, line 164, in read raise PipeTimeout() paramiko.buffered_pipe.PipeTimeout During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/home/satnau/.local/lib/python3.6/site-packages/netmiko/base_connection.py”, line 541, in _read_channel_expect new_data = self.remote_conn.recv(MAX_BUFFER) File “/home/satnau/.local/lib/python3.6/site-packages/paramiko/channel.py”, line 701, in recv raise socket.timeout() socket.timeout During handling of the above exception, another exception occurred: Traceback (most recent call last): File “DNS_PING_FIREWALL_TESTING_V2.0.py”, line 243, in <module> junos_fw_info = secmt_connect.send_command_expect(f’grep -w {ip}/32 *.set | grep book | grep -v 1b | grep -v 2b’, expect_string = ‘secmt junos-firewall’) File “/home/satnau/.local/lib/python3.6/site-packages/netmiko/base_connection.py”, line 1447, in send_command_expect return self.send_command(*args, **kwargs) File “/home/satnau/.local/lib/python3.6/site-packages/netmiko/base_connection.py”, line 1366, in send_command new_data = self.read_until_pattern(pattern=re.escape(cmd)) File “/home/satnau/.local/lib/python3.6/site-packages/netmiko/base_connection.py”, line 618, in read_until_pattern return self._read_channel_expect(*args, **kwargs) File “/home/satnau/.local/lib/python3.6/site-packages/netmiko/base_connection.py”, line 552, in _read_channel_expect “Timed-out reading channel, data not available.” netmiko.ssh_exception.NetmikoTimeoutException: Timed-out reading channel, data not available.
Thanks, Satish
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (7 by maintainers)
Top GitHub Comments
@satnau Does changing your column width on the Netmiko-linux SSH session prior to executing your long command fix your issue?
net_connect.send_command('stty cols 1023')
Kirk
@ktbyers - Yes the solution that you provided worked like a charm! Thanks a ton…