预期:无效的命令名称“*”

Expect: invalid command name "*"

在我的 Expect 脚本中,这一行抛出错误:

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

在日志中我看到这个错误:

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

括号中的远程主机IP地址可以更改。

Expect 使用 Tcl。在 Tcl 中,双引号中的 [...]command substitution 语法,类似于 Bash.

中的 $(...)(或 `...`

要包含文字 [ 字符,您可以这样写:

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