- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
谁能解释一下
expect_out(buffer)
expect_out(0,string)
通常我更喜欢使用 expect_out(buffer)
。
第二个是什么,我们什么时候可以使用它?
谁能解释一下?
最佳答案
您可能想看一下 manpage :
我会引用相关部分:
Upon matching a pattern (or eof or full_buffer), any matching and previously unmatched output is saved in the variable
expect_out(buffer)
. Up to 9 regexp substring matches are saved in the variablesexpect_out(1,string)
throughexpect_out(9,string)
. If the-indices
flag is used before a pattern, the starting and ending indices (in a form suitable forlrange
) of the 10 strings are stored in the variablesexpect_out(X,start)
andexpect_out(X,end)
where X is a digit, corresponds to the substring position in the buffer. 0 refers to strings which matched the entire pattern and is generated for glob patterns as well as regexp patterns. For example, if a process has produced output of"abcdefgh\n"
, the result of:expect "cd"is as if the following statements had executed:
set expect_out(0,string) cdset expect_out(buffer) abcdand
"efgh\n"
is left in the output buffer. If a process produced the output"abbbcabkkkka\n"
, the result of:expect -indices -re "b(b*).*(k+)"is as if the following statements had executed:
set expect_out(0,start) 1set expect_out(0,end) 10set expect_out(0,string) bbbcabkkkkset expect_out(1,start) 2set expect_out(1,end) 3set expect_out(1,string) bbset expect_out(2,start) 10set expect_out(2,end) 10set expect_out(2,string) kset expect_out(buffer) abbbcabkkkk
您可以看到 expect_out(0,string)
和 expect_out(buffer)
如何包含不同的字符串。
关于tcl - 关于 Expect 中的 expect_out(buffer),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18929761/
我有带有 expect5.45 的 Ubuntu 9.10(并且由于测试无法在不久的将来更改它)。Expect 正在运行,但我有(至少)两个问题。首先是 expect 似乎不匹配字符串“passwor
如果我将 expect 编码到 shell 脚本中,我将无法获得 $expect_out(buffer) 和 $expect_out(0,string) 的值。 下面是我编写的示例代码。 [Linu
我有一个这样的期望文件 #!/opt/tools/unsupported/expect-5.39/bin/expect spawn ssh -l user ip expect_after eof {e
谁能解释一下 expect_out(buffer) expect_out(0,string) 通常我更喜欢使用 expect_out(buffer) 。 第二个是什么,我们什么时候可以使用它? 谁能解
如果我想匹配 DEF_23使用以下正则表达式: expect { -re "DEF_\[0-9]*" set result $expect_out(1,string) } 为什么说no
我试图通过登录交换机来捕获“dir”命令的输出,但我无法这样做。我在 Bash 中使用 Expect。我正在使用 expect_out 在缓冲区中捕获该命令的输出并将其打印出来。实际上我想捕获输出并对
我是一名优秀的程序员,十分优秀!