GGospodinov
GGospodinov

Reputation: 33

Netmiko - confirmation in configuration mode

I just start using netmiko and have a problem with one script. The script should delete a user and create another one. The problem that I have is with confirmation in configuration mode I don`t know how to handle it.

R1(config)#no username admin
This operation will remove all username related configurations with same name.Do you want to continue? [confirm]

Thank you.

Upvotes: 1

Views: 2225

Answers (2)

Kirill Inkin
Kirill Inkin

Reputation: 1

Use ssh.send_command_timing()'

like this:

ssh.send_command_timing(f'no username {user}')

Upvotes: 0

onxx
onxx

Reputation: 1435

you would a use an expect string.

output = net_connect.send_command(
    command_string=command,
    expect_string=r"Delete filename",
    strip_prompt=False,
    strip_command=False
)
output += net_connect.send_command(
    command_string="\n",
    expect_string=r"confirm",
    strip_prompt=False,
    strip_command=False

Upvotes: 2

Related Questions