Send command with changing prompt #3731
SoerenBusse
started this conversation in
General
Replies: 1 comment
-
|
The typical pattern for situations similar to what you described are to use the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there,
we’re trying to use Netmiko with Huawei SmartAX devices. These devices have the peculiarity that certain interface-specific display commands must be run from within the corresponding interface configuration context.
Here’s an example:
The simplest approach we’ve found with Netmiko looks like this:
However, this results in a read timeout, due to the way
send_commandattempts to detect the prompt:_prompt_handleris called, which in turn callsfind_prompt(whenauto_find_prompt=True, the default).HOSTNAME(config)#, which_prompt_handlerreturns tosend_commandand stores assearch_pattern.49_441_1893_76Z4(config-if-mpu-0/8)#.search_patternno longer matches the new prompt, aReadTimeoutis raised.We’ve identified two potential workarounds:
auto_find_prompt=False, which makes Netmiko look only for thebase_prompt. But since the base prompt is usually just the hostname, this can cause issues if the command output also includes the hostname (Netmiko may interpret it as the prompt).expect_stringwith a regex such asHOSTNAME(>|#|(.*)#).Both approaches work, but they feel more like hacks than proper solutions.
What is the recommended way to use
send_commandwhen the command itself changes the device prompt?Beta Was this translation helpful? Give feedback.
All reactions