Cisco Expect

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
#!/usr/bin/expect
set timeout 5
set hostname "c3750"
set username "admin"
set password "sysadm"
spawn ssh -p 22 $username@$hostname
expect "password:" {
  send "$password\n"
  expect "#" {
    send "configure terminal\n"
  expect "#" {
    send "hostname $hostname\n"
    send "ip name-server 192.168.240.200\n"
    send "ip domain name xinux.org\n"
    send "ntp server 192.168.240.200\n"
  expect "#" {
    send "exit\n"
    send "copy running-config startup-config\n"
  expect "?" {
   send "\n"
   send "exit\n"
  }
  }
  }
  }
  interact
}