Você pode capturar a saída e analisá-la dentro do esperado
#!/usr/bin/expect -f
# connect to vplexcli
spawn vplexcli
# Look for login prompt
expect -re "Name:"
# Send login
send "service\r"
# Look for password prompt
expect -re "Password:"
# Send password
send "letmein123\r"
expect -re "VPlexcli:/> "
send "ll /clusters/cluster-1/storage-elements/\r"
expect -re "(.*)VPlexcli:/> "
foreach line [split $expect_out(1,string) \n] {
if {[string match *error* $line]} {
puts $line
}
}
send "exit\r"
expect eof