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



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

  • 1
    Do you have the contents of the script? That way we can see if its being properly executed? – ProfFrnswrth Nov 14 '14 at 15:23
  • yes pastebin.com/sSXRZd1s – Cris Nov 14 '14 at 15:34
  • Can we see the script here - or better just the bits needed to provide an example that fails - it should; not be via a link only – mmmmmm Nov 14 '14 at 16:10

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.

  • sorry...the last line was added by me cause it was the only way to make it work,the original file does not have the last line. – Cris Nov 14 '14 at 16:45
  • you were right ! – Cris Nov 14 '14 at 16:47
  • . path/to/new/script works...is what i wanted to do..wht is the diff between . path/to/new/script and ./path/to/new/script ? – Cris Nov 14 '14 at 16:49
  • Just to make it doubly sure, there is a space between the first . and the rest of the path => . /path/to/your/script – Raghav Nov 14 '14 at 16:55
  • Not semantically speaking...from execution perspective i asked – Cris Nov 14 '14 at 16:56

I assume (via the name) that this is a Weblogic environment setting script. It is usually called via the weblogic main script to set paths before starting/stopping the server - but you're trying to set paths within your own shell for whatever reason. I think your problem lays with the way you execute the script:

./setWLSEnv.sh # will execute the script and do nothing

. ./setWLSEnv.sh # (note starts with a "dot space") 

The proposed second line should "source" the script within your environment and it will work

Check why this would work, by reading "man bash" and search inside for the definition of "source"


In your file, replace PATH= with PATH=$PATH:. This takes the actual PATH variable and add all your new PATHs.

Add export PATH at the end of the file. This export the previous PATH with your changes.

export PATH
  • this behavior is only on MAC or on linux as well ? this script is provided by oracle weblogic and i doubt i have to modify it... – Cris Nov 14 '14 at 15:31
  • I added export path to the end but after script is done...the PATH content is gone as well :( – Cris Nov 14 '14 at 15:31
  • You can use in both MAC or linux. – jherran Nov 14 '14 at 15:33
  • Yes all this works for me as well if i run each command manually...my sh file pastebin.com/sSXRZd1s is coming from oracle weblogic used to set some variables before running some java stuff – Cris Nov 14 '14 at 15:40
  • So after running this ./setWLSEnv.sh the PATH variable is not modified like in the file even if i modify the file by adding at the end export PATH – Cris Nov 14 '14 at 15:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .