问题
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 \[*]? "
来源:https://stackoverflow.com/questions/51883910/expect-invalid-command-name