LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how to set the Environment variable from shell Scrit (https://www.linuxquestions.org/questions/linux-software-2/how-to-set-the-environment-variable-from-shell-scrit-492033/)

Sundaram 10-13-2006 04:05 AM

how to set the Environment variable from shell Scrit
 
I want to set the CPLUS_INCLUDE_PATH from my shell script file.

I tried the following way

export CPLUS_INCLUDE_PATH=.:/home/XXX/ABC/Include

I ran the script and I checked in the console

echo $CPLUS_INCLUDE_PATH it did not show the newly added include path.

anybody can help me.:Pengy:

Thanks in advance.

druuna 10-13-2006 04:23 AM

Hi,

If you set/export a (environment) variable inside a script, it will be lost after the script stops.
Exporting variables can only be exported from parent to child, not from child to parent.

You can source a file. I.e:
infile contains export FOO=/tmp

. infile will make FOO available in the current shell.

Hope this clears things up a bit.

Sundaram 10-13-2006 11:59 PM

Thanks for your information.


All times are GMT -5. The time now is 01:08 PM.