Help - Search - Members - Calendar
Full Version: Shell Programming, Why Won't Setting Path Stick.
Linuxhelp > Support > Technical Support

I'm a Java programmer who's a newbe with RedHat (ver 9). To set up my environment I've written a very symple shell program to set the PATH and CLASSPATH. However, once the shell program has terminated none of the changes stick. For example PATH is the same as it was before running the program. What the heck is going on??? Please tell, I've done this a zillion times on the iSeries and pSeries and the changes stayed. Here is a copy of what I'm talking about. I'm sure its something simple and easy, but man, I'm lost. Thanks

listing of my shell program.

-rwxrwxrwx 1 ferris ferris 40 Oct 22 20:46

[ferris@localhost java]$ head
export JAVA_HOME=":/usr/java/j2sdk1.4.2_02/bin/"
echo $PATH

here is my before PATH

[ferris@localhost java]$ echo $PATH

here I run the shell program and you can see the PATH has changed.

[ferris@localhost java]$ ./

now here is the PATH afterwards. As you can see, it does change in the program does not stick, its the same.

[ferris@localhost java]$ echo $PATH
[ferris@localhost java]$

Nothing sticks at this point, no PATH, no CLASSPATH not even JAVA_HOME.
You have to export any variables that you want to stay after the script is the variable JAVA_HOME should be there after you are finished running the script ... do the command:

env | grep JAVA_HOME

and see if it stays...

Change the script like this:


or this


and you should be OK ... also get rid of the : in front of $JAVA_HOME if you are going to put it in the front of path...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.