MacOS – Running a .sh file but after new PATH is not visible in shell

bashcommand linemacosterminal

I am running a file ./setWLSEnv.sh which has the following output:

http://pastebin.com/sSXRZd1s

    PATH=/Users/cris/Oracle/Middleware/Oracle_Home/wlserver/server/bin:/Users/cris/Oracle/Middleware/Oracle_Home/wlserver/../oracle_common/modules/org.apache.
ant_1.9.2/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/H
ome/jre/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin:
/Users/cris/perl5/perlbrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbi
n:/sbin:/opt/X11/bin:/Users/cris/Oracle/Middleware/Oracle_Home/wlser
ver/../oracle_common/modules/org.apache.maven_3.0.5/bin


Your environment has been set.

BUT when i go in the same terminal and i execute

echo PATH is still have the old path …

Any idea ? Thanks

Best Answer

You can't run a script to set the path in your current shell. In your case this does not seem to be necessary anyway because all the script does is to set up the correct variables to run the java process at the end. So inside this process all environment variables should be set correctly.

To set variables in the current shell, either set them in .bashrc/.bash_profile and open a new shell; or duplicate your script, remove the last line and source the new script into the shell with . path/to/new/script.