Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Shell Programming, Why Won't Setting Path Stick., shell programming.
cjferris
post Nov 10 2003, 09:54 PM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 1
Joined: 10-November 03
Member No.: 1,783



Hello

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 setpath.sh program. What the heck is going on??? Please tell, I've done this a zillion times on the iSeries and pSeries and the setpath.sh 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 shell1.sh

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

here is my before PATH

[ferris@localhost java]$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/ferris/bin

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

[ferris@localhost java]$ ./setpath.sh
:/usr/java/j2sdk1.4.2_02/bin/:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/ferris/bin

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
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/ferris/bin
[ferris@localhost java]$

Nothing sticks at this point, no PATH, no CLASSPATH not even JAVA_HOME.
blink.gif
Go to the top of the page
 
+Quote Post
hughesjr
post Nov 11 2003, 09:16 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



You have to export any variables that you want to stay after the script is run...so 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:

PATH="$JAVA_HOME:$PATH"; export PATH

or this

export PATH="$JAVA_HOME:$PATH"

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...


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 20th October 2017 - 04:43 PM