期望:将生成命令的输出存储到变量中 [英] expect: store output of a spawn command into variable

查看:82
本文介绍了期望:将生成命令的输出存储到变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的期望脚本中:

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

这将存储在变量 LOG中的内容:16345(内存位置)。

What this will store in the variable "LOG": 16345 (memory location).

它应存储在变量 LOG中的内容: svn commit的某些消息日志。

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

执行bash命令然后将输出存储到Expect变量中似乎是一个问题。

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

您有任何想法吗?

推荐答案

您不需要在那里生成。

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)

这篇关于期望:将生成命令的输出存储到变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆