想用期望脚本建立一个 Auth Smtp 连接......只是为了测试我想获取 ehlo 参数但期望不能像这样工作
#!/usr/bin/expect
set timeout -1
set smtp [lindex $argv 0]
set port [lindex $argv 1]
spawn telnet $smtp $port
expect "[2]{2,}[0]{1,}"
send "ehlo\n"
我希望代码 220 来自邮件服务器以继续发送 ehlo ...就像
..../...:telnet smtp.mail.yahoo.de 25
Trying 77.238.184.85...
Connected to smtp2-de.mail.vip.ukl.yahoo.com.
Escape character is '^]'.
220 smtp116.mail.ukl.yahoo.com ESMTP
ehlo
250-smtp116.mail.ukl.yahoo.com
250-AUTH LOGIN PLAIN XYMCOOKIE
250-PIPELINING
250-SIZE 41697280
250 8BITMIME
错误说:
spawn telnet smtp.mail.yahoo.de 25
invalid command name "2"
while executing
"2"
invoked from within
"expect "[2]{2,}[0]{1,}""
(file "./login.exp" line 6)
如果我只写期望“220”而不是期望“[2]{2,}[0]{1,}”它可以工作但忽略发送“ehlo\n”