cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
344
Views
2
Helpful
2
Replies

python script error

LegiaP8741
Level 1
Level 1

i got following error 

Checking for VIOS-ADVENTERPRISEK9-M
Software version found: VIOS-ADVENTERPRISEK9-M
Running VIOS-ADVENTERPRISEK9-M commands
Traceback (most recent call last):
File "netmiko6.py", line 74, in <module>
output = net_connect.send_config_set(commands_list_router)
File "/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py", line 111, in wrapper_decorator
return_val = func(self, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py", line 2325, in send_config_set
output += self.read_until_pattern(
File "/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py", line 748, in read_until_pattern
raise ReadTimeout(msg)
netmiko.exceptions.ReadTimeout:

Pattern not detected: '(?:R1.*$|#.*$)' in output.

2 Accepted Solutions

Accepted Solutions

Hey @LegiaP8741 from the error you encountering is a 'ReadTimeout' exception, which is raised by Netmiko when it doesn't detect a specific pattern in the output within a certain time period. You see the pattern is (?:R1.*$|#.*$), which is a regular expression (I had to decode that!) that matches either the string "R1" followed by any characters until the end of the line, or a "#" character followed by any characters until the end of the line.


This normally occurs when you device does not respond as expected, or when the command takes too long to execute. If you can reach the device by ssh from the host machine running the code ok, in the first instance, i would increase your timeoutout like this.
 
net_connect = ConnectHandler(**device)
net_connect.timeout = 60  # increase timeout to 60 seconds

Try this. Hope it helps. If you want, share your full code if the above does not work.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

View solution in original post

Martin L
VIP
VIP

what is line 74, in <module> ? output = net_connect.send_config_set(commands_list_router)

I meant what is in command list ? what type of commands, etc?

take a look at ur commands_list_file and remove any notes, markings, remarks in ur command list file; Any inconclusive IOS commands; Add "!" between lines of commands if ur list is too long; also add time out 60 s mentioned above.   

Regards, ML
**Please Rate All Helpful Responses **

View solution in original post

2 Replies 2

Hey @LegiaP8741 from the error you encountering is a 'ReadTimeout' exception, which is raised by Netmiko when it doesn't detect a specific pattern in the output within a certain time period. You see the pattern is (?:R1.*$|#.*$), which is a regular expression (I had to decode that!) that matches either the string "R1" followed by any characters until the end of the line, or a "#" character followed by any characters until the end of the line.


This normally occurs when you device does not respond as expected, or when the command takes too long to execute. If you can reach the device by ssh from the host machine running the code ok, in the first instance, i would increase your timeoutout like this.
 
net_connect = ConnectHandler(**device)
net_connect.timeout = 60  # increase timeout to 60 seconds

Try this. Hope it helps. If you want, share your full code if the above does not work.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Martin L
VIP
VIP

what is line 74, in <module> ? output = net_connect.send_config_set(commands_list_router)

I meant what is in command list ? what type of commands, etc?

take a look at ur commands_list_file and remove any notes, markings, remarks in ur command list file; Any inconclusive IOS commands; Add "!" between lines of commands if ur list is too long; also add time out 60 s mentioned above.   

Regards, ML
**Please Rate All Helpful Responses **