expect: store output of a spawn command into variable

ぃ、小莉子 提交于 2020-01-07 03:53:06

问题


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).

What it should store in the variable "LOG": "some message of the svn commit log".

It seems like the is a problem with executing a bash command and then storing that output into an expect variable.

Have you got any ideas? I am new to expect and tcl.


回答1:


You did't need spawn there. Try:

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

If you really want to use spawn:

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


来源:https://stackoverflow.com/questions/45036988/expect-store-output-of-a-spawn-command-into-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!