#!/usr/bin/expect
set timeout 5
set hostname [lindex $argv 0]
set username "username"
set password "password"
set enablepassword "password"
spawn telnet $hostname
expect "Username:" {
send "$username\n"
expect "Password:"
send "$password\n"
expect ">" {
send "en\n"
expect "Password:"
send "$enablepassword\n"
}
interact
}