gpt4 book ai didi

linux - xterm 不继承expect脚本中的环境变量

转载 作者:太空宇宙 更新时间:2023-11-04 05:29:46 24 4
gpt4 key购买 nike

我有一个可打开 xterm 的 Expect 脚本

我发现我需要使用“exec”才能打开 xterm

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

虽然我发现可以在我的脚本中使用多个命令,但不能在 xterm 脚本中使用。

后来我发现所有当前的环境变量都没有在该 xterm 中设置

为什么?经常使用 bash,以前从未遇到过这个问题。如何让xterm继承所有环境变量?

最佳答案

独立于expect,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

关于linux - xterm 不继承expect脚本中的环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23857835/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com