Search pattern never detected in send_command_expect:

See original GitHub issue

Hi Ktbyers, I am having an issue with my script . it does not write to my output file anything related to the command rather it give me me and error this is the error that i got

File “C:\Users\LEJDEFF\AppData\Local\Programs\Python\Python37\lib\site-packages\netmiko-2.3.3-py3.7.egg\netmiko\base_connection.py”, line 1320, in send_command_expect OSError: Search pattern never detected in send_command_expect: I

My script is as below

#!/usr/bin/env python
import netmiko
import sys
import datetime
from netmiko import ConnectHandler
from getpass import getpass

device = {
    'device_type': 'cisco_ios',
    'host': '172.24.237.130',
    'username': 'brunolepu401',
    'password': getpass(),
    
} 

net_connect = ConnectHandler(**device)
#open file to write command output
#file = open('_outputtexte', 'w')

# Execute commands
output = net_connect.send_command_expect('sh run', delay_factor=60)

# Write output to file above

filename = 'output' + '{0:%Y-%m-%d-%H-%M-%S}'.format(datetime.datetime.now()) + '.txt'
file = open(filename, 'w')
file.write(output)

#with open(filename) ad fh:
#line=fh.readline()
#line = fp.readline()
#   cnt = 1
#  while line:
#       print("Line {}: {}".format(cnt, line.strip()))
#       line = fp.readline()
#       cnt += 1

#print('Le nombre de sessions est de :',cnt )
file.close()

Can you please help Ktbyers

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jrlerichecommented, Jun 20, 2019

@carlniger , @ktbyers I realized what the issue was it is just because of an authentication issue. It was not accepting the command terminal length 0 from netmiko. then I was not having anything in ly output file. the logging session showed everything. Thanks Guys

0reactions
ktbyerscommented, May 10, 2022

Logging setup is here:

https://github.com/ktbyers/netmiko/blob/develop/COMMON_ISSUES.md#enable-netmiko-logging-of-all-reads-and-writes-of-the-communications-channel

You can also look at the session log by adding the session_log argument to your device / ConnectHandler call:

device = {
    'device_type': 'cisco_ios',
    'host': '172.24.237.130',
    'username': 'brunolepu401',
    'password': getpass(),
    'session_log': 'my_file.out',  
} 
Read more comments on GitHub >

github_iconTop Results From Across the Web

Netmiko OSError: Search pattern never detected in ...
send_command is pattern-based. Meaning it searches for the device prompt to detect the end of output. for BaseConnection in netmiko ...
Read more >
Search pattern never detected in send_command_expect · ...
@CharlesZuo01 The problem is that the above IOS command prompts you to confirm (i.e. the router prompt is not returned which is what...
Read more >
Python // Misc: Netmiko and what constitutes “done”
Netmiko is going to search for the trailing router prompt (the backslash escaping of ... Search pattern never detected in send_command_expect: pynet\-rtr1\#.
Read more >
Handling Prompts from sent commands - Patrick Denis
OSError: Search pattern never detected in send_command_expect: since it is waiting for an input. It need more actions .
Read more >
Python and Netmiko : r/networking
The issue I get stuck with is line 7. It waits there and times out with a"Search pattern never detected in send_command_expect:". I...
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