why don't export commands work in bash_profile - Setup

This is a discussion on why don't export commands work in bash_profile - Setup ; I have some commands ie. export XXX=YYY which work after I have logged in. When I try to put those commands in script file like bash_profile and run it, they don't seem to work. Do I need some different commands ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: why don't export commands work in bash_profile

  1. why don't export commands work in bash_profile


    I have some commands ie. export XXX=YYY which work after I have logged
    in.

    When I try to put those commands in script file like bash_profile and
    run it, they don't seem to work.

    Do I need some different commands or options to make them work?


  2. Re: why don't export commands work in bash_profile

    On 2006-10-07, voipfc@googlemail.com wrote:
    >
    > I have some commands ie. export XXX=YYY which work after I have logged
    > in.
    >
    > When I try to put those commands in script file like bash_profile and
    > run it, they don't seem to work.


    ~/.bash_profile is only sourced by login shells. Other interactive
    shells source ~/.bashrc.

    > Do I need some different commands or options to make them work?


    --
    Chris F.A. Johnson, author |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

  3. Re: why don't export commands work in bash_profile

    voipfc@googlemail.com wrote:
    > I have some commands ie. export XXX=YYY which work after I have logged
    > in.
    >
    > When I try to put those commands in script file like bash_profile and
    > run it, they don't seem to work.


    How are you running the script? If you run it in the normal way, a new
    shell is started to interpret the script and the export commands effect
    only that shell and processes started from it. If you want to run the
    script in the current shell so that the export commands set variables
    in the current environment you must use the "source" command to execute
    the script.

    --
    Markku Kolkka
    markku.kolkka@iki.fi



+ Reply to Thread