期望:检查字符串是否不是另一个字符串的子字符串

时间:2017-08-08 09:25:27

标签: expect

#!/usr/bin/expect

set timeout 20
set user [lindex $argv 0]
set password [lindex $argv 1]

spawn su $user
expect "Password:"

send "$password\r";

expect {
        #"*" {puts "Login successfulklk"; exit 0}
        timeout {puts "Unable to su user"; exit -1}
        "su: incorrect password" {puts "Incorrect Password" ; exit -1}
        eof {puts "Closed \n";exit -1}
        "!su: incorrect password]*" {puts "Login successfull"; exit 0}
}

我想在expect中检查一个字符串(" su:密码错误")不是另一个字符串的子字符串。

0 个答案:

没有答案