04-10-2024 08:52 PM
I'm trying to write a python script using netmiko to update the before-login banner on two exos switches. I came across this solved post about the same thing but that code didn't work for me and I'm unsure why. Here is the exos 'sh version' and my current script.
Successful execution in terminal.
Then when I run the 'show banner' command on either switch it returns nothing since the banner wasn't changed from the default blank one.
Solved! Go to Solution.
04-12-2024 10:38 AM
I figured out why Netmiko was ignoring the trailing banner text input prompt. After enabling session logging for netmiko directly in my script I was able to review what netmiko sent to to my target device's console as input.
Apparently, netmiko sends a few commands of it's own. One of those is 'disable cli prompting' which is what disables the banner text input. I ended up just sending the command 'enable cli prompting' before my configure banner command in my script and everything worked.
Bonus tip: if you're trying to do similar on vyos just import vymgmt into your script. You'll have to download it if not already on your system. I didn't have any cli prompt issue with vyos though.
04-12-2024 10:38 AM
I figured out why Netmiko was ignoring the trailing banner text input prompt. After enabling session logging for netmiko directly in my script I was able to review what netmiko sent to to my target device's console as input.
Apparently, netmiko sends a few commands of it's own. One of those is 'disable cli prompting' which is what disables the banner text input. I ended up just sending the command 'enable cli prompting' before my configure banner command in my script and everything worked.
Bonus tip: if you're trying to do similar on vyos just import vymgmt into your script. You'll have to download it if not already on your system. I didn't have any cli prompt issue with vyos though.
05-21-2024 06:32 AM
May I ask how your final script looks? I've been running into roadblocks with this and can't seem to get it figured out. I tried to match the initial script you provided to see if it worked but I'm still getting errors or blank outputs for the banner.