自动登录过BSO的脚本

来源:互联网 发布:服务器同步备份软件 编辑:程序博客网 时间:2024/05/18 01:44
 这个脚本是同事写的, 当然, 之前我自己也写了一个, 但没有像他下面一样加异常, 其余都是一样的. 记录一下, 以后要用直接用.

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

0 0
原创粉丝点击