question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pattern not found in output: #

See original GitHub issue

Hi,

I just started on netmiko; thanks to all of you, especially Kirk, for this.

The problem I am facing is as below: Here is the exeption I am having for a test config-change in one of the ports:

Traceback (most recent call last): File “remoteConfigurePort.py”, line 27, in <module> device.send_config_set(config_commands) File “C:\Program Files\Python38\lib\site-packages\netmiko\base_connection.py”, line 1704, in send_config_set output = self.config_mode(*cfg_mode_args) File “C:\Program Files\Python38\lib\site-packages\netmiko\cisco_base_connection.py”, line 40, in config_mode return super().config_mode(config_command=config_command, pattern=pattern) File “C:\Program Files\Python38\lib\site-packages\netmiko\base_connection.py”, line 1595, in config_mode if not self.check_config_mode(): File “C:\Program Files\Python38\lib\site-packages\netmiko\cisco\cisco_ios.py”, line 29, in check_config_mode return super().check_config_mode(check_string=check_string, pattern=pattern) File “C:\Program Files\Python38\lib\site-packages\netmiko\cisco_base_connection.py”, line 30, in check_config_mode return super().check_config_mode(check_string=check_string, pattern=pattern) File “C:\Program Files\Python38\lib\site-packages\netmiko\base_connection.py”, line 1582, in check_config_mode output = self.read_until_pattern(pattern=pattern) File “C:\Program Files\Python38\lib\site-packages\netmiko\base_connection.py”, line 618, in read_until_pattern return self._read_channel_expect(*args, **kwargs) File “C:\Program Files\Python38\lib\site-packages\netmiko\base_connection.py”, line 563, in _read_channel_expect raise NetmikoTimeoutException( netmiko.ssh_exception.NetmikoTimeoutException: Timed-out reading channel, pattern not found in output: #

The source code is given below:

config_commands = ['interface gigabitEthernet 1/0/35','switchport access vlan 20']
start = time.time()
for i in ipdb:    
    for cmd in commands:
        device = ConnectHandler(device_type='cisco_ios_telnet', ip=i, username='***', password='***') 
        device.send_config_set(config_commands)
        print ("Done!")
        device.disconnect()

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
nullbitzerocommented, Apr 29, 2020

Hi @m6461 ,

In a telnet session a switch or router, first enter user mode (‘>’) where you enter the command enable to switch to privileged mode (‘#’). To use the send_config_set () method you must be previously in the privilege, this is how the code is thought.

https://www.cisco.com/E-Learning/bulk/public/tac/cim/cib/using_cisco_ios_software/02_cisco_ios_hierarchy.htm

nullbit0

1reaction
nullbitzerocommented, Apr 29, 2020

Hi, try this command line

device = ConnectHandler(device_type=‘cisco_ios_telnet’, ip=i, username=‘‘, password=’’) find_prompt=device.send_command(‘\n’) if not ‘#’ in find_prompt: #–>optional device.enable()#—>optional according to your device telnet device.send_config_set(config_commands,expect_string=‘#’) print (“Done!”) device.disconnect()

good luck! nullbit0

Read more comments on GitHub >

github_iconTop Results From Across the Web

python regex: pattern not found - Stack Overflow
When I run this program, nothing happens. I it not able to catch these patterns, what is am I doing wrong here? Desired...
Read more >
Netmiko4 read_timeout - Python for Network Engineers
ReadTimeout : Pattern not detected: 'cisco3\\#' in output. Things you might try to fix this: 1. Explicitly set your pattern using the ...
Read more >
"pattern not found" ??? - UNIX and Linux Forums
When editing/viewing files with the vi editor, whenever I try to exit I get a "pattern not found" message. This message occurs even...
Read more >
bash script pattern not found - Unix & Linux Stack Exchange
Your grep runs over the file (once) and prints all lines that match at least one of the patterns, so the output is...
Read more >
4.1. The grep Command
If you wanted all the lines that contained pattern to be printed, ... if the pattern is not found, there will be no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found