TCL Expect Script to Bring Lab Up

My Lab enviornment is running on a server with around 10 router-simulators. Without script, I have to login server by using SSH session first, then TELNET to dynagen session to interact with router simulator. This job is tedious. So, I came up with some script to automate my routing job.

First, we need a Tcl script for each connection.

#!/usr/bin/expect

spawn ssh root@10.2.111.198
expect “password:”
send “d7j3f8g8\n”
expect “root@common-server”
send “telnet 127.0.0.1 2000\n”
interact

There are two key parts. One is “expect “password:”. TCL Expect has a nice feature that you can send a password to interact with shell command. The other is “interact” command. Without it, we cannot interupt TCL session.

Then, we can put all start router-simulator script to a bash shell.

gnome-terminal -e ./open_router_sim.tcl

Discussion Area - Leave a Comment




Spam Protection by WP-SpamFree Plugin