TCL Expect Script to automate telnet connectivity to Cisco switch

To write the script, the telnet process between the client (Ubuntu) and server (switch) should be analyzed. A telnet connection is initiated from the ubuntu system to the switch, using the command telnet 192.168.1.30. The output of the command is shown below

It can be observed that apart from the prompt “switch”, which in the router connection process was “router”, rest of the connection procedure and parameters are the same.

telnetautomatetcl2

The following script automates the above process.

Create a file telnetswitchautomate.tcl using the command vi telnetswitchautomate.tcl on the Ubuntu system. The screenshot of the code in the script, is provided below. The code is self explanatory, as it is similar to the telnet automation script with the router, with the change in the “Switch” prompt

Python Network Programming CourseClick Here