return = fail
这对我来说不无所作为,因为就我而言,这并不是一件大事,只会使我再次面临同样的问题。 我无法说明如何使其与在我发言之前的打印文本相匹配。
expect_out (to fix above solution) = fail
The manual says:
Upon matching a pattern (or eof or full_buffer), any matching and previously unmatched output is saved in the variable expect_out(buffer).
但我看不到工作(除我下文使用外,加上<代码>-indices<>/code>,使工作在那里进行,也没有设想如何使以前的产出纳入新的<代码>expect{......>。)
expect_user
解决办法,使用expect_user
我没有做任何工作,要么是因为我没有解释,要么没有使用我所希望的方式,那么,我不知道如何在我的实际预期档案中应用这一有限的例子。
my solution
So what I did instead was avoid the interactive mode, and just have a way to provide input, one line at a time. It even works for arrow keys and alt+...
, (in dpkg Dialog questions) but not for simply <enter>
sometimes (hit alt+y for <Yes>
or alt+o for <Ok>
for those in dpkg Dialog). (anyone know how to send an enter? not
, but the enter key like dpkg Dialog wants?)
<代码>i 用户_spawn_id 部分意思是,它不只检查你的间谍程序,而是检查用户类型。 这影响到以后的一切,因此,你使用<代码>expect_ subsequently。 或将其置于其余部分,而不是expect_ before
.-indices
,从而使其能够读到与正常表述相当的部分。 expect_out(1,string)
是I想要的部分(除殖民地外)。
expect_after {
-i $user_spawn_id
# single line custom input; prefix with : and the rest is sent to the application
-indices -re ":(.*)" {
send "$expect_out(1,string)"
}
}
采用<代码>expect_ subsequently,即该代码将适用于所有下列条目:expect
。 直至下一个<代码>expect_ subsequently。 因此,你可以在卷宗中将这一条放在你通常的<代码>expect上。
and my case/purpose
I wanted to automate do-release-upgrade which does not properly support the usual Debian non-interactive flags (see here)...it just hangs and ignores input instead of proceeding after a question. But the questions are unpredictable... and an aborted upgrade means you could mess up your system, so some fallback to interaction is required.