#!/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:密码错误")不是另一个字符串的子字符串。