JAVA_HOME not picked up as en var

Discussion in 'Java' started by lbrtchx@hotmail.com, May 4, 2007.

  1. Guest

    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
     
    , May 4, 2007
    #1
    1. Advertising

  2. Guest

    In article <>,
    <> wrote:
    > 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

    --
    B. L. Massingill
    ObDisclaimer: I don't speak for my employers; they return the favor.
     
    , May 4, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aliasgar Pocketwala

    ASP.NET application wrong culture picked up

    Aliasgar Pocketwala, Jul 17, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    672
    Mario Vargas
    Jul 17, 2003
  2. Bennett Haselton
    Replies:
    5
    Views:
    616
    Bennett Haselton
    Aug 19, 2003
  3. Miss Michelle. Heigardt
    Replies:
    8
    Views:
    143,971
    abbinv
    Apr 9, 2011
  4. Guest
    Replies:
    0
    Views:
    494
    Guest
    Oct 25, 2006
  5. aidy
    Replies:
    2
    Views:
    101
    Carlos
    Aug 14, 2006
Loading...

Share This Page