Quantcast
Viewing all articles
Browse latest Browse all 21

Another TestLab Script

I’m sorry that all of these TestLab scripts are a recurring theme. Work purchased four 3560s and two 1841s for the lab so I have been updating all of my scripts. When I was working on the lab I kept having sessions hang so I wrote a quick script to clear all of the lines on the terminal server.

#!/usr/bin/expect
# 2010-12-14 Jud Bishop
# tl-clear
# A short script to handle logging into a router in the lab.

set host "testlab.chainringcircus.org"
set pass "CHANGEME"
set enable "CHANGEME2"
set ctrlz \032

##############################
# Should not need any more changes.

spawn telnet $host
expect "Password:"
send "$pass\r"
expect "testlab>"
send "enable\r"
expect "Password:"
send "$enable\r"
expect "testlab#"
sleep 1

for { set i 1} {$i < 48} {incr i 1} {
    send "clear line $i\r"
    expect {
        -re ".*confirm.*" {send "y \r"}
        -re ".*Not allowed to clear current line.*" {send "\r"}
        -re ".*Invalid input detected at.*" {send "\r"}
    }
}
exit

Viewing all articles
Browse latest Browse all 21

Trending Articles