JAVA_HOME not picked up as en var

L

lbrtchx

Why wouldn't this work?
~
#!/bin/bash

MNT=/mnt/sdb5
JAVA_HOME=${MNT}/JApps/jdk/jdk1.6.0_01
export JAVA_HOME
echo $JAVA_HOME

PATH=${JAVA_HOME}/bin:$PATH
export PATH
echo $PATH

TOMCAT_HOME=/mnt/sdb5/JApps/tc/apache-tomcat-6.0.10
export TOMCAT_HOME
echo $TOMCAT_HOME
~
root@0[kd]# ls -l *.sh
-rwxr-xr-x 1 root root 241 May 4 16:51 javakpath00.sh
~
root@0[kd]# which bash
/bin/bash
~
root@0[kd]# bash -version
GNU bash, version 3.00.16(1)-release (i386-pc-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.
~
lbrtchx
 
B

blmblm

Why wouldn't this work?
~
#!/bin/bash

MNT=/mnt/sdb5
JAVA_HOME=${MNT}/JApps/jdk/jdk1.6.0_01
export JAVA_HOME
echo $JAVA_HOME

[ snip ]

Executing a script in the normal way (./thescript, for example)
creates a subshell, and any environment variables you set are
set for the subshell -- and not passed back to the parent shell.
Hence your script has no effect on its caller's environment
variables.

To get the effect I think you want, you need to instead "source"
the script. If you're also using bash as your interactive
shell, you'd say

source ./thescript

or

. ./thescript
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top