I have an installation script that gives out the following prompt:

Please type a selection or press "Enter" to accept default choice [1]:

I cannot make expect catch it. I tried to play around the equates surrounding Enter, but nothing seems to work.

Any ideas would be welcome

  • See if echo "" | /path/to/installation/script will suffice, to send a newline to the command's stdin. Commented Feb 26, 2018 at 14:57

1 Answer 1


There are 2 types of problems with trying to match strings like "[1]".

Firstly, expect uses tcl strings and [] are special characters inside double-quotes, so you either need to escape them with \[, or you need to use brace quotes {} instead.

Secondly, expect patterns are by default glob patterns, so [abc] means match an a, b or c character. So you either need to escape the [ a second time, or you can use option -ex to say you do not want to use a glob, but an exact string.

So the resulting command that should work is

expect -ex {default choice [1]:}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .