自動登入過BSO的指令碼
阿新 • • 發佈:2018-11-01
這個指令碼是同事寫的, 當然, 之前我自己也寫了一個, 但沒有像他下面一樣加異常, 其餘都是一樣的. 記錄一下, 以後要用直接用.
#!/usr/bin/expect
set username "****@163.com"
set password "password"
#Passing one of the IPs bellow maybe pass others.
set ip_list {
vs370.rch.kstart.com
9.123.100.210
}
set timeout 5
foreach {ip} $ip_list {
if [catch {
spawn telnet $ip
expect "Username:"
send "$username\r"
expect "Password:"
send "$password\r"
#wait to authenticate
expect {
"Successful" {puts "pass bso for $ip sucessfully."}
timeout {puts "you maybe have passed bso for $ip sucessfully."}
}
close
} result] {
puts "you maybe have passed bso for $ip sucessfully."
}
}