Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, This is a script that should set and add some path to some variables: Code: [root@skynet script]# cat XSB.sh #!/bin/sh XSB_PATH=/app/XSB export XSB_PATH XSB_CONF_PATHNAME=$SERVICEBROKER_PATH/cfg/XSB.cfg export XSB_CONF_PATHNAME PATH=$PATH:$XSB_PATH/bin export PATH ...
  1. #1
    Just Joined!
    Join Date
    Mar 2008
    Posts
    30

    Adding my app path to PATH variable - not working

    Hi,

    This is a script that should set and add some path to some variables:
    Code:
    [root@skynet script]# cat XSB.sh
    #!/bin/sh
    
    XSB_PATH=/app/XSB
    export XSB_PATH
    
    XSB_CONF_PATHNAME=$SERVICEBROKER_PATH/cfg/XSB.cfg
    export XSB_CONF_PATHNAME
    
    PATH=$PATH:$XSB_PATH/bin
    export PATH
    
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$XSB_PATH/lib
    export LD_LIBRARY_PATH
    
    [root@skynet script]# ./XSB.sh
    
    [root@skynet script]# echo $XSB_CONF_PATHNAME
    
    [root@skynet script]# echo $PATH
    /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
    Do you have any idea why my app path is not added ?

    Thanks,
    Bianca
    Last edited by devils casper; 03-31-2008 at 12:08 PM.

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Do you have any idea why my app path is not added ?
    Sure.

    Every process that you run has a parent process, the process that started the process in question. When a process starts, it (almost always) inherits the values of the environment variables of the parent. That process is free to change the values of those environment variables, but when the process finishes, any changed values do not cause the corresponding environment variables in the parent to change.

    When you run your script thus:
    Code:
    ./XSB.sh
    that script is run in a new process. When that script is done, the process goes away. The environment changes in that process do not take effect in the parent process. (In this case, the parent process is the one running your shell at the command line.)

    What you want is to run that shell script as part of your current process. One way is this:
    Code:
    source ./XSB.sh
    Another way to "spell" that has exactly the same effect:
    Code:
    . ./XSB.sh
    Note the extra period and space at the beginning.

    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...