简体   繁体   English

期望:将生成命令的输出存储到变量中

[英]expect: store output of a spawn command into variable

Inside my "expect" script: 在我的“期望”脚本中:

set $REPOS "/path/to/repo/"
set $REV 73
set LOG [spawn svnlook log -r $REV $REPOS]

What this will store in the variable "LOG": 16345 (memory location). 这将存储在变量“ LOG”中的内容:16345(内存位置)。

What it should store in the variable "LOG": "some message of the svn commit log". 它应该存储在变量“ LOG”中的内容:“ svn commit log的某些消息”。

It seems like the is a problem with executing a bash command and then storing that output into an expect variable. 执行bash命令然后将输出存储到Expect变量中似乎是一个问题。

Have you got any ideas? 你有什么主意吗? I am new to expect and tcl. 我是新来的期望和TCL。

You did't need spawn there. 您不需要在那里生成。 Try: 尝试:

set LOG [exec svnlook log -r $REV $REPOS]

If you really want to use spawn: 如果您真的想使用spawn:

spawn vnlook log -r $REV $REPOS
expect
set LOG $expect_out(buffer)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM