Expect: Any way to match a specific rule only once?

32 Views Asked by At

I am working on an expect program to ssh into a server and run a few commands.

I have a rule which goes

-re ".*└─.*" {
        send "echo Done backing up!\n"
        send "echo Thanks! \n"
        send "exit \n"
        exp_continue
    }

(the ascii box characters are to match the ZSH prompt, using wildcards because the prompt has color.)

Currently, the program goes into an infinite loop since pressing enter causes another prompt to appear.

Is there any way to make expect match the rule only once? A temporary workaround i have found is chaining the commands with ; and only sending \n after exit.

I have tried searching for anything related to expect and "expect match once"

Glossing over the pages of Exploring Expect, I still do not see anything.

0

There are 0 best solutions below