如何从expect中获取输出
我编写了一个脚本来生成 bc 命令
package require Expect
proc bc {eq} {
spawn e:/GnuWin32/bc/bin/bc
send "$eq\r"
expect -re "(.*)\r"
return "$expect_out(0,string)"
}
set foo "9487294387234/sqrt(394872394879847293847)"
puts "the valule [bc $foo]"
如何从中获取输出。当我运行这个时,我得到这样的输出:
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
9487294387234/sqrt(394872394879847293847)
477
can't read "expect_out(0,string)": no such element in array
while executing
"return "The values is $expect_out(0,string)""
(procedure "bc" line 6)
invoked from within
"bc $foo"
invoked from within
"puts "the valule [bc $foo]""
(file "bc.tcl" line 21)
如何解决这个问题。
i wrote a script for spawing the bc
command
package require Expect
proc bc {eq} {
spawn e:/GnuWin32/bc/bin/bc
send "$eq\r"
expect -re "(.*)\r"
return "$expect_out(0,string)"
}
set foo "9487294387234/sqrt(394872394879847293847)"
puts "the valule [bc $foo]"
how to get the output from this. When i am running this one i get ouput like this
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
9487294387234/sqrt(394872394879847293847)
477
can't read "expect_out(0,string)": no such element in array
while executing
"return "The values is $expect_out(0,string)""
(procedure "bc" line 6)
invoked from within
"bc $foo"
invoked from within
"puts "the valule [bc $foo]""
(file "bc.tcl" line 21)
how to resolve this one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是它与您的期望不符。 (提示 Jamie Zawinski 的引言。)
试试这个:
我得到这个输出......
The problem is that it's not matching what you expect. (Cue the Jamie Zawinski quote.)
Try this:
I get this output...