expect if condition extra characters after close-quote while executing

huangapple go评论62阅读模式
英文:

expect if condition extra characters after close-quote while executing

问题

以下是您要翻译的部分:

我正在尝试执行此代码来处理自动化执行中可能发生的多个选择,但在此执行中有时会发生内部错误,并且发送“^”将使其继续到下一步,但我的代码失败。

这是代码:

expect {
    "Enter RETURN to continue or '^' to exit:"
    {send "^\n"; exp_continue }
    "Select Systems Manager Menu Option:"
}
send "fm\n"

错误信息:

关闭引号后的额外字符
    在执行时
    {send "^\n"; exp_continue }
    在其中调用

我尝试使用以下代码来解决此问题,但由于大括号内的双引号,我没有完全找到错误在哪里。

英文:

i am trying execute this code to handle multiple selections may occurs in the automation execution ,however in this execution sometimes an internal error occurs and sending "^" will make it continue to the next step but my code fails .

this is the code

expect {
"Enter RETURN to continue or '^' to exit:"

{send "^\n",exp_continue }

"Select Systems Manager Menu Option:"
}
send "fm\n"

the error

extra characters after close-quote
    while executing
"send "^\n",exp_continue "
    invoked from within
"expect {
-ex "Enter RETURN to continue or '^' to exit:"

{send "^\n",exp_continue }

-ex "Select Systems Manager Menu Option:"
}"
    (file "./ClinicStop_extract.sh" line 29)
[root@localhost cron]#

i tried to handle this problem with this code but i didn't get exactly where is the mistake in it since the double quotes inside the {}

答案1

得分: 1

你需要在那一行上有两个语句,所以你需要使用分号来分隔它们,而不是逗号,即:

{send "^\n"; exp_continue }

英文:

You have two statements on that line, so you need a semicolon to separate them, not a comma, i.e.

{send "^\n"; exp_continue }

huangapple
  • 本文由 发表于 2023年5月28日 18:09:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76350954.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定