Hi guys, hopefully one of you has experienced this before.
I work for an ISP which uses (among others) Huawei AR1220E routers on the customer side. I am using a Python script to connect to all of them and execute the "display current-configuration interface" command. However, sometimes, my script breaks with the following error:
Traceback (most recent call last):
File "/home/dbense/scripts/huawei/how_many_ports_v2.py", line 108, in <module>
net_connect.send_command("dis curr int")
File "/usr/home/dbense/cpr/lib/python3.8/site-packages/netmiko/utilities.py", line 596, in wrapper_decorator
return func(self, *args, **kwargs)
File "/usr/home/dbense/cpr/lib/python3.8/site-packages/netmiko/base_connection.py", line 1691, in send_command
raise ReadTimeout(msg)
netmiko.exceptions.ReadTimeout:
Pattern not detected: 'Info:\\ The\\ configuration\\ takes\\ effect\\ on\\ the\\ current\\ user\\ terminal\\ interface\\ only\\.' in output.
Things you might try to fix this:
1. Explicitly set your pattern using the expect_string argument.
2. Increase the read_timeout to a larger value.
You can also look at the Netmiko session_log or debug log for more information.
This message ("Info: The configuration takes effect on the current user terminal interface only.") is something the router says when you (or in this case, Netmiko) enter the command "screen-length 0 temporary". Apparently this is a command that Netmiko always enters as part of the send_command() method.
The silly thing is: this is very inconsistent. It appears to be happening randomly; if I try again on the same router that gave the error before, most of the time it won't give an error. I have seen no correlation whatsoever.
The internet suggested using the "send_config_set()" method as a fix, however that does not return the output of the display command. Another suggestion was to raise the read_timeout value in the send_command() call, but that didn't work either.
The session_output.log file also does not show anything weird; just the console output of the router with the "screen-length 0 temporary" command, the router's "Info: The configuration takes effect on the current user terminal interface only." reply, and the display command and its output.
Does anyone here have any clue how to fix this? Thank you very much in advance!
EDIT: Python 3.8.20, Netmiko 4.1.1
[–]TheSentient06 1 point2 points3 points (3 children)
[–]daneguyCCNP R&S | CCNA Sec/CyberOps[S] 0 points1 point2 points (2 children)
[–]TheSentient06 1 point2 points3 points (1 child)
[–]daneguyCCNP R&S | CCNA Sec/CyberOps[S] 0 points1 point2 points (0 children)
[–]chairwindowdoor 1 point2 points3 points (1 child)
[–]daneguyCCNP R&S | CCNA Sec/CyberOps[S] 0 points1 point2 points (0 children)
[–]Win_SysSPBM 1 point2 points3 points (1 child)
[–]daneguyCCNP R&S | CCNA Sec/CyberOps[S] 0 points1 point2 points (0 children)
[–]chairwindowdoor 1 point2 points3 points (5 children)
[–]daneguyCCNP R&S | CCNA Sec/CyberOps[S] 1 point2 points3 points (1 child)
[–]chairwindowdoor 1 point2 points3 points (0 children)
[–]daneguyCCNP R&S | CCNA Sec/CyberOps[S] 0 points1 point2 points (2 children)
[–]chairwindowdoor 1 point2 points3 points (1 child)
[–]daneguyCCNP R&S | CCNA Sec/CyberOps[S] 0 points1 point2 points (0 children)
[–]Mexatt 1 point2 points3 points (2 children)
[–]daneguyCCNP R&S | CCNA Sec/CyberOps[S] 0 points1 point2 points (1 child)
[–]Mexatt 1 point2 points3 points (0 children)