Expect: invalid command name “*”

2019-08-28 20:44发布

问题:

In my Expect script this line is throwing an error:

expect "Address or name of remote host [*]? "

In the log I see this error:

switchnumber1#invalid command name "*"
    while executing
"*"
    invoked from within
"expect "Address or name of remote host [*]? ""

The remote host ip address in the brackets could change.

回答1:

Expect uses Tcl. In Tcl, [...] in double quotes is the command substitution syntax which is like $(...) (or `...`) in Bash.

To include a literal [ char you could write:

expect "Address or name of remote host \[*]? "


标签: expect