如何访问Expect脚本中的环境变量? [英] How to access environment variables in an Expect script?
本文介绍了如何访问Expect脚本中的环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想访问期望脚本中的PATH环境变量。
I would like to access the PATH environment variable inside an expect script.
如何实现?
我的实际脚本是:
#!/usr/bin/expect
set timeout 300
send "echo $PATH\r"
其输出是:
can't read "PATH": no such variable
while executing
"send "echo $PATH\r""
推荐答案
Expect是 Tcl的。 Tcl通过全球 env
数组访问环境变量:
Expect is an extension of Tcl. Tcl access enviroment variables via the global env
array:
send_user "$env(PATH)\n"
这篇关于如何访问Expect脚本中的环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文