CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Installation (https://www.cfd-online.com/Forums/openfoam-installation/)
-   -   Setting environment variables: bash issue (https://www.cfd-online.com/Forums/openfoam-installation/105401-setting-environment-variables-bash-issue.html)

travonz July 30, 2012 04:29

Setting environment variables: bash issue
 
Hello,

I would like to automate environment initialization prior to OpenFOAM use.
I wrote the following bash script, but it doesn't work at all. Environment is only set inside script, when it exit the script and goes back to console, nothing changes, no variable has been defined.

#!/bin/bash
source /opt/OpenFOAM/OpenFOAM-2.1.1/etc/bashrc
source $HOME/.bashrc
cd $FOAM_RUN

Do you know how can I keep environment after script execution ?

Thanks for your help.

Xavier

wyldckat July 30, 2012 17:12

Greetings Xavier and welcome to the forum!

You should resort to an alias instead, placed in your "~/.bashrc". Example for your case:
Code:

alias of211combo='source /opt/OpenFOAM/OpenFOAM-2.1.1/etc/bashrc; cd $FOAM_RUN'
For more on this kind of details: Advanced tips for working with the OpenFOAM shell environment

Best regards,
Bruno

travonz July 31, 2012 03:17

Great !

Thank you very much for your advice and for the link.

sincerely,

Xavier


All times are GMT -4. The time now is 01:58.