Шаблон Netmiko не обнаруженPython

Программы на Python
Ответить
Anonymous
 Шаблон Netmiko не обнаружен

Сообщение Anonymous »

Я выполнил этот код на коммутаторе Cisco 2960X.

Код: Выделить всё

from netmiko import ConnectHandler

network_device= {
"host": "192.168.xxx.xxx",
"username": "xxxx",
"password": "xxxx",
"device_type": "cisco_ios",
"session_log": "netmiko_session.log"
}

connect= ConnectHandler(**network_device)
connect.enable()

interface_name= "GigabitEthernet1/0/10"

def send_command(command):
return connect.send_command(command)
try:
send_command('enable')
send_command('configure terminal')
except Exception as e:
print(e)
print("Failed!")
Но после того, как я получил ошибку ниже.

Код: Выделить всё

Pattern not detected: 'Switch\\#' 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.

Failed!
Пожалуйста, проверьте ниже netmiko_session.log

Код: Выделить всё

Switch#
Switch#terminal width 511
Switch#terminal length 0
Switch#
Switch#enable
Switch#
Switch#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#
Я переименовал имя хоста коммутатора. Но происходит та же ошибка.

Подробнее здесь: https://stackoverflow.com/questions/748 ... t-detected
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»