Expect Script Query

Hi,
I am writing an expect script, but i have come into a problem ... I have two different answers to one command.
This is fine, but I do not know when I will see which answer - Is there anyway I could put an expect answer into an if statement, like so:

if { expect == "1" } {
send "working\n"
else
send "bye\n"
}

any ideas how I can get past this - it seems like a simply enough query, but I have searched google and found nothing ... any idea??

thanks ..

I think you're looking for this

This behaves much like if, else

Expect Scripting, Turorial Expect Scripts

Hi Radar,
Thanks for your quick reply - however I have seen this example before and it isn't really what I am looking for.

Depending on my answer, I have different questions to ask ... That is why I was looking for an if statement.

if scenario 1 do this, otherwise do the other ...

Using your example, can I do this:

expect "hi" { send "You said hi\n" }
expect "Yes, I said hi" send ....
"hello" { send "Hello yourself\n" }
expect "Yes, I said hello" send ....
"bye" { send "Good-bye cruel world\n" }
expect "Good luck" send ....

Thanks again for your help

Better off with:

expect {
-re "(.)hi" { perform action }
-re "(.
)hello" { perform action }
-re "(.*)bye" { perform action }
}

With a -re it will match to anything entered that has "hi" or "hello" or "bye" in it ....