Automate Telnet Login to CISCO Device with Expect

Step 1: Install expect (Centos 6.7 32bit)
yum install expect

Step 2: Verify expect install correct
expect –v

Step 3: Create Working Folder for Script
cd $HOME
mkdir CiscoAutomation
cd CiscoAutomation

Step 4: Create expect script with vi
vi TestCISCOLogin.exp

รจScript file contents
#!/usr/bin/expect
set timeout 10
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

}

Comments

Popular posts from this blog

Basic Send Message to MQ with Java and IBM MQ JMS

Basic Receive Message to MQ with Java and IBM MQ JMS

Configure Database Connection using MyBatis