cancel
Showing results for 
Search instead for 
Did you mean: 

Python script to update login banner

Python script to update login banner

nembrey
New Contributor

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.

nembrey_4-1712807487099.png

nembrey_2-1712806875994.png

 

Successful execution in terminal.

nembrey_3-1712806891025.png

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.

 

1 ACCEPTED SOLUTION

nembrey
New Contributor

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.

nembrey_0-1712943166123.png

nembrey_1-1712943291168.png

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.

 

View solution in original post

2 REPLIES 2

nembrey
New Contributor

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.

nembrey_0-1712943166123.png

nembrey_1-1712943291168.png

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.

 

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. 

 

GTM-P2G8KFN