自动登录过BSO的脚本

版权声明: https://blog.csdn.net/oFengWuYu1/article/details/71703290
 这个脚本是同事写的, 当然, 之前我自己也写了一个, 但没有像他下面一样加异常, 其余都是一样的. 记录一下, 以后要用直接用.

#!/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."
    }
}

猜你喜欢

转载自blog.csdn.net/oFengWuYu1/article/details/71703290
今日推荐