Saturday, 23 July 2011

How to export variables by a script in bash?

If you do not use bash more often but form time to time you can have a similar problem. Just before running java application from command line you would like to set up some system variables. So setting up them is done in a script. If you run it, those variables will be set only for time of script execution, as they will be created in a separate environment. What is the solution?

Just run script with preceding . or source

. ./script.sh

source ./script.sh

This time script will run within the existing shell. This is what we wanted!

No comments: