Version 5 of Expect and choice

Updated 2008-08-11 21:31:30 by escargo

[Make time to explain recurring question about expecting alternatives.]

Model question: "need something like 'if expect is {y/n} send y; if not, send quit'". Skeleton answer:

    expect {
        y/n {
            send y\r
        }
        timeout {
            send quit\r
        }
    }

The above code confuses me a bit - it looks as if it sends along to the program a "y" if the user types "y/n" - was that intentional?

escargo 11 Aug 2008 - That would seem to be a restatement of the model question. As long as the timeout is reasonable, it should work. Better would be to anticipate some other alternatives so that waiting for the timeout is less necessary.