分类:
2006-02-23 03:48:47
#!/usr/bin/expect -f set username xiaosuo set hostname nkbbs.org set timeout -1 spawn telnet -8 $hostname # send the user name expect { "防止使用程式上站" { send "\003" # send Ctrl + C exp_continue } "请输入帐号" { send "$username\r" } } # send the password expect { "无此 ID" { puts "没有这个用户名,请检察" exit } "只能从主机登陆" { puts "SYSOP 只能从主机登陆" exit } "不可从此IP登录本站" { puts "不可从此IP登录本站" exit } "没有得到email验证" { puts "注册信息没有得到email验证。请回复后用WEB登陆自动激活" exit } "请输入密码" { } } # get the password from the user stty -echo expect_user -notransfer -re "(.*)\n" # so BT, no space between '1' and 'string', waste me much time set password $expect_out(1,string) stty echo send "$password\r" # check the password expect { "密码输入错误" { puts "密码错误" exit } -re "按.*键继续" { send "\r" } "您想删除重复的 login 吗" { send "\r\r" } } # jump the issue for {set i 0} {$i<2} {incr i} { send "\r" } expect { "您要删除以上密码输入错误的记录吗" { send "Y\r" exp_continue } -re "好朋友列表" { send "q" exp_continue } -re {\(.*[0-9][0-9]:[0-9][0-9].*\):} { send "\r" exp_continue } -re "主选单" { send "e\r" } } # Somebody want to chat with you. expect_after { -re {\(.*[0-9][0-9]:[0-9][0-9].*\):} { send "r我是挂BBS机器人!:)\r" } } set timeout 10 # Keep alive loop. while {1} { expect { timeout { send "e\r" } } } |