现在的位置: 首页 > 综合 > 正文

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

2014年02月18日 ⁄ 综合 ⁄ 共 877字 ⁄ 字号 评论关闭

                                                                                           自动登录过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."
    }
}

抱歉!评论已关闭.