One of the reasons would be that you’re not taking care of timeouts.
I’ve written this script which should work (attached telnet2.txt)
When you run it, it’ll ask you for the switch IP, username and password
You should see something like this:
Last login: Wed Jul 3 11:22:18 from 10.83.36.204
ats324...11:29:40#terminal length 0
Hope it helps! Thanks,
Awesome. It works perfectly.
I changed line 28: switch_output instead of siwtch_output (simple typing error, I write this for others)
As you wrote before: “One of the reasons would be that you’re not taking care of timeouts.”
Thank you very much :)
Also, I saw that adding a delay is extremely important. I tried without that and it doesn’t work. Why do we have to add this delay? If I want to configure 20 VLANs and give each one a name (VLAN_1, VLAN_2 etc) it requires 40 seconds only for that. Imagine a script with far more commands…isn’t there a better option?
Sorry for the typo, I must’ve copy pasted the script before I corrected it. As the comment says terlminal lenghth 0 disables pagination, so when you run show commands that have longer outputs, it disables the –More– prompt
There is a better option, as I mentioned, we highly recommend using eAPI, it will take under 1 second to configure 100 vlans.
You can either use eAPI with jsonrpclib (a good starter would be: https://eos.arista.com/arista-eapi-101/) or you can use a wrapper like pyeapi:
or goeapi or ruby eapi
Using an SSH lib like netmiko would be also much faster than telnetlib and it’s compatible with most of the vendors.
Ansible would also be a good option, which can use either SSH or eAPI to connect to EOS/vEOS/cEOS.
Perfect, thank you.
Post your Answer
You must be logged in to post an answer.