预期:无效的命令名称"*"; [英] Expect: invalid command name "*"

查看:94
本文介绍了预期:无效的命令名称"*";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 [*]? ""

括号中的远程主机ip地址可能会更改.

The remote host ip address in the brackets could change.

推荐答案

期望使用Tcl.在Tcl中,双引号[...]命令替换语法类似于Bash中的$(...)(或`...`).

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 \[*]? "

这篇关于预期:无效的命令名称"*";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆