You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having trouble storing the output of the Cisco IOSXE command "install remove inactive" using netmiko to a variable so that I can then look inside that output to see if a particular string exists. Let me explain...
The output of "install remove inactive" will ultimately end with "Do you want to remove the above files? [y/n]" if files exist that should be removed, or the device's trailing prompt if there are no files to remove. Doing something like this ... output = device.send_command("install remove inactive")
... doesn't cut it because this can't account for both outputs.
...which shouldn't look for any particular prompt, but it appears that nothing is stored in output because the print statement returns a blank.
A possible issue is that the timeout is shorter than it takes for the CLI to produce all the output related to this command. I found that it takes the CLI around 3:30 to produce the final line of output. That being the case, I tried manipulating the delay_factor...
..but no luck with this either. Perhaps I'm misunderstanding something about the timeout and delay_factor because it only takes about 6 seconds before it moves to the print line, which prints nothing.
I would like to add that this works just fine and produces the expected list of interface when the print statement runs...
output = device.send_command_timing(command_string="show int status", delay_factor=3)
print(f"{output}")
If it helps, here's an example of the output I'm expecting to exist within output after issuing the "install remove inactive" command...
install_remove: START Wed Dec 1 22:56:51 EST 2021
Cleaning up unnecessary package files
No path specified, will use booted path flash:packages.conf
Cleaning flash:
Scanning boot directory for packages ... done.
Preparing packages list to delete ...
cat9k-cc_srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-espbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-guestshell.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpboot.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipspa.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-webui.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-wlc.16.09.04.SPA.pkg
File is in use, will not delete.
packages.conf
File is in use, will not delete.
done.
Cleaning up unnecessary package files
No path specified, will use booted path flash:packages.conf
Cleaning flash:
Scanning boot directory for packages ... done.
Preparing packages list to delete ...
cat9k-cc_srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-espbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-guestshell.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpboot.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipspa.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-webui.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-wlc.16.09.04.SPA.pkg
File is in use, will not delete.
packages.conf
File is in use, will not delete.
done.
SUCCESS: No extra package or provisioning files found on media. Nothing to clean.
Cleaning up unnecessary package files
No path specified, will use booted path flash:packages.conf
Cleaning flash:
Scanning boot directory for packages ... done.
Preparing packages list to delete ...
cat9k-cc_srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-espbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-guestshell.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpboot.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipspa.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-webui.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-wlc.16.09.04.SPA.pkg
File is in use, will not delete.
packages.conf
File is in use, will not delete.
done.
SUCCESS: No extra package or provisioning files found on media. Nothing to clean.
Cleaning up unnecessary package files
No path specified, will use booted path flash:packages.conf
Cleaning flash:
Scanning boot directory for packages ... done.
Preparing packages list to delete ...
cat9k-cc_srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-espbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-guestshell.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpboot.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipspa.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-webui.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-wlc.16.09.04.SPA.pkg
File is in use, will not delete.
packages.conf
File is in use, will not delete.
done.
SUCCESS: No extra package or provisioning files found on media. Nothing to clean.
The following files will be deleted:
[switch 1]:
/flash/cat9k_iosxe.16.12.04.SPA.bin
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all,
I'm having trouble storing the output of the Cisco IOSXE command "install remove inactive" using netmiko to a variable so that I can then look inside that output to see if a particular string exists. Let me explain...
The output of "install remove inactive" will ultimately end with "Do you want to remove the above files? [y/n]" if files exist that should be removed, or the device's trailing prompt if there are no files to remove. Doing something like this ...
output = device.send_command("install remove inactive")
... doesn't cut it because this can't account for both outputs.
So I tried....
...which shouldn't look for any particular prompt, but it appears that nothing is stored in
output
because the print statement returns a blank.A possible issue is that the timeout is shorter than it takes for the CLI to produce all the output related to this command. I found that it takes the CLI around 3:30 to produce the final line of output. That being the case, I tried manipulating the delay_factor...
..but no luck with this either. Perhaps I'm misunderstanding something about the timeout and delay_factor because it only takes about 6 seconds before it moves to the print line, which prints nothing.
I would like to add that this works just fine and produces the expected list of interface when the print statement runs...
If it helps, here's an example of the output I'm expecting to exist within
output
after issuing the "install remove inactive" command...install_remove: START Wed Dec 1 22:56:51 EST 2021
Cleaning up unnecessary package files
No path specified, will use booted path flash:packages.conf
Cleaning flash:
Scanning boot directory for packages ... done.
Preparing packages list to delete ...
cat9k-cc_srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-espbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-guestshell.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpboot.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipspa.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-webui.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-wlc.16.09.04.SPA.pkg
File is in use, will not delete.
packages.conf
File is in use, will not delete.
done.
Cleaning up unnecessary package files
No path specified, will use booted path flash:packages.conf
Cleaning flash:
Scanning boot directory for packages ... done.
Preparing packages list to delete ...
cat9k-cc_srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-espbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-guestshell.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpboot.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipspa.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-webui.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-wlc.16.09.04.SPA.pkg
File is in use, will not delete.
packages.conf
File is in use, will not delete.
done.
SUCCESS: No extra package or provisioning files found on media. Nothing to clean.
Cleaning up unnecessary package files
No path specified, will use booted path flash:packages.conf
Cleaning flash:
Scanning boot directory for packages ... done.
Preparing packages list to delete ...
cat9k-cc_srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-espbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-guestshell.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpboot.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipspa.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-webui.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-wlc.16.09.04.SPA.pkg
File is in use, will not delete.
packages.conf
File is in use, will not delete.
done.
SUCCESS: No extra package or provisioning files found on media. Nothing to clean.
Cleaning up unnecessary package files
No path specified, will use booted path flash:packages.conf
Cleaning flash:
Scanning boot directory for packages ... done.
Preparing packages list to delete ...
cat9k-cc_srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-espbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-guestshell.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-rpboot.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipbase.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-sipspa.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-srdriver.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-webui.16.09.04.SPA.pkg
File is in use, will not delete.
cat9k-wlc.16.09.04.SPA.pkg
File is in use, will not delete.
packages.conf
File is in use, will not delete.
done.
SUCCESS: No extra package or provisioning files found on media. Nothing to clean.
The following files will be deleted:
[switch 1]:
/flash/cat9k_iosxe.16.12.04.SPA.bin
Do you want to remove the above files? [y/n]
Beta Was this translation helpful? Give feedback.
All reactions