Solved

Why? java path not coming before /usr/bin

Posted on 2014-02-11
4
261 Views
Last Modified: 2014-02-21
ok, how come the java path is not coming before /usr/bin

.profile
PATH=/usr/java71/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin.

export PATH

if [ -s "$MAIL" ]           # This is at Shell startup.  In normal
then echo "$MAILMSG"        # operation, the Shell checks
fi                          # periodically.

# User specific aliases and functions
export AS_JAVA=/usr/java71
export JAVA_HOME=/usr/java71
export JAVA_BINDIR="${JAVA_HOME}/bin"
echo $PATH | /bin/grep -q -v "${JAVA_BINDIR}"
if [ $? -eq 0 ]; then export PATH="${JAVA_BINDIR}:${PATH}"; fi
echo $PATH
export GLASSFISH_PARENT=/u01/oracle/glassfish
export GLASSFISH_HOME=/u01/oracle/glassfish/glassfish
echo $PATH | /bin/grep -q -v "${GLASSFISH_HOME}/bin"
if [ $? -eq 0 ]; then export PATH="${PATH}:${GLASSFISH_HOME}/bin"; fi
echo $PATH

Open in new window


Then I run the following and it shows /usr/java71/bin is in front of /usr/bin/
but then
$ ./.profile
[YOU HAVE NEW MAIL]
/usr/java71/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/glassfsh/bin:/usr/bin/X11:/sbin.
/usr/java71/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/glassfsh/bin:/usr/bin/X11:/sbin.:/u01/oracle/glassfish/glassfish/bin
$ echo $PATH
/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/glassfsh/bin:/usr/bin/X11:/sbin:/usr/java71/bin.:/u01/oracle/glassfish/glassfish/bin

Open in new window

0
Comment
Question by:bcarlis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39851626
You must "source" the .profile, i.e. run it inside the current shell, like this

. ./.profile

dot space dot slash dot profile

Didn't I mention that in our previous thread?
0
 
LVL 2

Author Comment

by:bcarlis
ID: 39854032
Yes you did but I thought Sandys was same and it returned the email msg so I thought it did it ???
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 150 total points
ID: 39854228
Without the "dot space" in front the .profile script is executed in a subshell of the current shell.

Such a subshell can well execute commands or display messages which you can see on your terminal.

The only thing is that environment variables set in a subshell do not become known to the parent shell - you can set and work with these variables as long as you're in the subshell (the script). As soon as the subshell script exits all variables set there are lost (resp. return to the value they had before).
0
 
LVL 2

Author Closing Comment

by:bcarlis
ID: 39877430
Sorry got busy with the "Next" thing :)
Thank you so much for your help.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question