[英]I am trying to export tcl buffer to bash variable
我正在尝试将tcl缓冲区导出到bash变量,但我无法使其正常工作。
我希望下面的例子能使我清楚我要完成的工作。
我一定要一个tcl嵌入脚本
======================================
#!/bin/bash
var=bash_to_tcl
expect -c "
puts lindex $argv 0
expect "xx"
send "123\n"
set $var $expect_out(buffer) <<<< setting the variable to export to bash>>>>>>
}
exit 0
<<< >> =====================================
echo $var "tcl_to_bash" (THIS IS WHERE I AM HAVING ISSUES) <<<<<<<<<<<<<<<<<<<
=====================================
我一直在寻找示例的线索,但找不到任何线索。 我得到了尊重,但无法将输出导出回bash
子进程(期望)不能更改父进程(bash)的环境。 通常,信息通过stdio通道在进程之间传递:
#!/bin/bash
# this is how bash captures the output of the expect program
var=$(expect -c '
spawn ...
expect "xx"
send "123\n"
# here is expect sending the info back to the parent
puts $expect_out(buffer)
')
do something with "$var"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.