开发者

set environment variables calling script file

I have a requirement where I have to set environment variables calling a script file eg:set_env.sh. set_env.sh contains all the environment variables.

export SCRIPT_DIR=/e/scripts/
...

when I call the set_env.sh from my code the variables are available in that file itself. They are not available in f开发者_Python百科ile where I have called the script.

What should be done so that environment variables can be retained and can be used in file which calls set_env.sh.


Using . set_env.sh works - thanks.

Some related links with explanation:

  • http://www.tldp.org/LDP/abs/html/abs-guide.html#SOURCEREF
  • http://www.linuxquestions.org/questions/linux-newbie-8/how-to-export-environment-variable-from-a-bash-script-344057/


You need to do

. set_env.sh

This runs set_env.sh in your current shell, rather than starting a new one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜