Posted on July 3, 2019 11:24 am
 |  Asked by Davide Ganna
Print Friendly, PDF & Email

Since I have problems posting the question, the Arista Support suggested me to attach the message as a.jpg file.
Please refer to the image, my post is written there.

Posted by Tamas Plugor
Answered on July 3, 2019 11:35 am

Hi Davide,

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:

Enter switch IP:
Username: cvpadmin

Last login: Wed Jul 3 11:22:18 from

ats324...11:29:40#terminal length 0
Pagination disabled.
ats324...11:29:42(config)#interface Ethernet2
ats324...11:29:43(config-if-Et2)#description TELNET-test
ats324...11:29:44(config-if-Et2)#no switchport
ats324...11:29:45(config-if-Et2)#ip address

Ultimately it'd be better to use eAPI, much faster and simpler then using telnet The following guide should be helpful:

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)
And I replaced line 39 with connection.write(“enable n”) because I got some errors cause we need to enter enable mode. What does “connection.write(“terminal length 0n”)” mean?

As you wrote before: “One of the reasons would be that you’re not taking care of timeouts.”
Shouldn’t be the timeout disabled if I don’t set that?

Thank you very much :)

(Davide Ganna at July 4, 2019 7:56 am)

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?

(Davide Ganna at July 4, 2019 9:34 am)

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.
Telnetlib is very slow and unoptimized, you can play with the timeouts, like lower them, but based on my tests you cannot go sub-second, this is true for connecting to linux VMs as well.

You can either use eAPI with jsonrpclib (a good starter would be: 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.

(Tamas Plugor at July 4, 2019 3:12 pm)

Perfect, thank you.


(Davide Ganna at July 5, 2019 7:08 am)

Post your Answer

You must be logged in to post an answer.