自動登錄過BSO腳本 ( by quqi99 )


                                                                                           自動登錄過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."
    }
}




注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2021 ITdaan.com