Core Coding®

Cisco Expect Script

  Cisco Expect Script
An expect script to automatically log into cisco routers.
#!/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
}

Go back to resources
Home Mail GitHub