自动登录过BSO脚本 ( by quqi99 )

来源:互联网 发布:网络技术发展 编辑:程序博客网 时间:2024/04/30 11:35

                                                                                           自动登录过BSO脚本 ( by quqi99 )


作者:张华  发表于:2012-05-07
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明

( http://blog.csdn.net/quqi99 )


              这个脚本是同事写的, 当然, 之前我自己也写了一个, 但没有像他下面一样加异常, 其余都是一样的. 记录一下, 以后要用直接用.

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



原创粉丝点击