xterm不会在expect脚本中继承环境变量

时间:2014-05-25 17:07:03

标签: linux bash shell unix expect

我有一个打开xterm的期望脚本

我发现我需要使用" exec"为了打开xterm

exec xterm -e '...here is an expect script also..'

虽然我认为在我的脚本中使用多个命令是可以的,但不能在那个xterm脚本中使用。

后来我发现当前的环境变量没有在那个xterm中设置

为什么呢?使用bash一些,从来没有遇到过这个问题。如何让xterm继承所有环境变量?

1 个答案:

答案 0 :(得分:0)

独立于预期UNIX / Linux有一条经验法则:

If you want to transfer a variable from parent process to its child process,
you must export this variable in the parent process.

您可以使用命令

检查是否已导出变量XYZ
env|grep XYZ