expect: telnet2switch
#!/usr/bin/expect
if {$argc != 1} {
puts "usage: ./telnet2sswitch <r2|r3>"
exit
}
if {"[lindex $argv 0]" == "r0"} {set ip 192.168.130.10 }
if {"[lindex $argv 0]" == "r1"} {set ip 192.168.130.11 }
if {"[lindex $argv 0]" == "r2"} {set ip 192.168.130.12 }
if {"[lindex $argv 0]" == "r3"} {set ip 192.168.130.13 }
user=admin
passwd=xxx
spawn telnet $ip
expect "Login:" {send "$user\r"}
expect "Password:" {send "$passwd\r"}
interact

浙公网安备 33010602011771号