shell 编程中export 的问题

我在用qt embedded.每次运行之前都要进行路径设置。
export QTDIR=/root/qte
想做一个shell命令文件,但是却没有效果。
vim eee
只有一句:
export QTDIR=/root/qte

保存后chmod 这个文件,使其可以执行。
但是执行后却没有效果,QTDIR没有被设置,还是要手工输入才行
这是为什么?
请大家多多指教。
谢先

---------------------------------------------------------------

你可以在~/.bashrc等配置文件中加入: export QTDIR=/root/qte
以后就不用每次设了.
---------------------------------------------------------------

如果是redhat9,在用户目录的.bash_profile中或/etc/profile中加
---------------------------------------------------------------

$source eee 就可以了
---------------------------------------------------------------

你的shell实际是在sub shell中运行,而非当前的login shell。在sub shell中对其所在环境的改变随着运行结束而消失。
解决方法有2:
1.在你login shell的配置文件(.profile之类)中加入 export ...
2.使你的shell script在当前shell中运行,即:"source yourshellname"

Published At
Categories with 服务器类
Tagged with
comments powered by Disqus