Skip to content

send_command not searching for default device prompt but something else #3730

@mrwatts

Description

@mrwatts

When we call send_command without an expected output, Netmiko should look for the default device prompt, but it sometimes doesn't.

Example code:

        pattern_files = r"Do you want to remove the above files\? \[y\/n\]"
        pattern_success = r"SUCCESS: install_remove"

        # Connect to the device
        with ConnectHandler(**device_connect_info) as net_connect:
            output = net_connect.send_command(
                "install remove inactive", f"({pattern_files}|{pattern_success})"
            )
            if pattern_success in output:
                msg = f"No unused installation files on {device.host_name} to remove."
                logger.debug(msg)
            else:
                output = net_connect.send_command("y")

                msg = f"Unused installation files have been removed from {device.host_name}."
                logger.debug(msg)

        logger.debug(f"Cleanup of installation files on {device.host_name} completed.")

This code causes an exception on the line:

output = net_connect.send_command("y")

The exception is:

netmiko.exceptions.ReadTimeout: 
Pattern not detected: '\\[y/n\\]' in output.

It is unclear to us why Netmiko is expecting a [y/n] prompt here and not the standard device prompt.

We're on Netmiko 4.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions