Bash environment variables not setting [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite













This question already has an answer here:



  • How can I make environment variables “exported” in a shell script stick around?

    2 answers



I am trying to configure the AWS CLI using a bash script. I have the below in my script and it will not set the values. When I echo out the variables names it just shows a blank line.



script code



export AWS_ACCESS_KEY_ID=<key>

export AWS_SECRET_ACCESS_KEY=<secret_key>

export AWS_DEFAULT_REGION=<region>









share|improve this question













marked as duplicate by Kusalananda linux
Users with the  linux badge can single-handedly close linux questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Aug 15 at 13:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • how are you trying to print the variables ... contents (not names)? After/outside the script, or within the script?
    – Jeff Schaller
    Aug 15 at 13:15











  • You have to source the script instead of running it.
    – Rui F Ribeiro
    Aug 15 at 13:16










  • I am trying to echo out the variables because they are not working. I these values are to be used by the AWS cli program. I am testing the echo outside the script once it has ran.
    – Josh Kirby
    Aug 15 at 13:17










  • @RuiFRibeiro What do you mean?
    – Josh Kirby
    Aug 15 at 13:17






  • 1




    @JoshKirby, please edit your question to include a complete example of a script that exhibits the issue, along with a sample of how you run the script. sh -c 'export ID=foo; echo "$ID"' should work with whatever sh you have, so there's not enough information here to tell what the issue is.
    – ilkkachu
    Aug 15 at 13:21














up vote
0
down vote

favorite













This question already has an answer here:



  • How can I make environment variables “exported” in a shell script stick around?

    2 answers



I am trying to configure the AWS CLI using a bash script. I have the below in my script and it will not set the values. When I echo out the variables names it just shows a blank line.



script code



export AWS_ACCESS_KEY_ID=<key>

export AWS_SECRET_ACCESS_KEY=<secret_key>

export AWS_DEFAULT_REGION=<region>









share|improve this question













marked as duplicate by Kusalananda linux
Users with the  linux badge can single-handedly close linux questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Aug 15 at 13:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • how are you trying to print the variables ... contents (not names)? After/outside the script, or within the script?
    – Jeff Schaller
    Aug 15 at 13:15











  • You have to source the script instead of running it.
    – Rui F Ribeiro
    Aug 15 at 13:16










  • I am trying to echo out the variables because they are not working. I these values are to be used by the AWS cli program. I am testing the echo outside the script once it has ran.
    – Josh Kirby
    Aug 15 at 13:17










  • @RuiFRibeiro What do you mean?
    – Josh Kirby
    Aug 15 at 13:17






  • 1




    @JoshKirby, please edit your question to include a complete example of a script that exhibits the issue, along with a sample of how you run the script. sh -c 'export ID=foo; echo "$ID"' should work with whatever sh you have, so there's not enough information here to tell what the issue is.
    – ilkkachu
    Aug 15 at 13:21












up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:



  • How can I make environment variables “exported” in a shell script stick around?

    2 answers



I am trying to configure the AWS CLI using a bash script. I have the below in my script and it will not set the values. When I echo out the variables names it just shows a blank line.



script code



export AWS_ACCESS_KEY_ID=<key>

export AWS_SECRET_ACCESS_KEY=<secret_key>

export AWS_DEFAULT_REGION=<region>









share|improve this question














This question already has an answer here:



  • How can I make environment variables “exported” in a shell script stick around?

    2 answers



I am trying to configure the AWS CLI using a bash script. I have the below in my script and it will not set the values. When I echo out the variables names it just shows a blank line.



script code



export AWS_ACCESS_KEY_ID=<key>

export AWS_SECRET_ACCESS_KEY=<secret_key>

export AWS_DEFAULT_REGION=<region>




This question already has an answer here:



  • How can I make environment variables “exported” in a shell script stick around?

    2 answers







linux aws






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 15 at 13:14









Josh Kirby

1




1




marked as duplicate by Kusalananda linux
Users with the  linux badge can single-handedly close linux questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Aug 15 at 13:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Kusalananda linux
Users with the  linux badge can single-handedly close linux questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Aug 15 at 13:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • how are you trying to print the variables ... contents (not names)? After/outside the script, or within the script?
    – Jeff Schaller
    Aug 15 at 13:15











  • You have to source the script instead of running it.
    – Rui F Ribeiro
    Aug 15 at 13:16










  • I am trying to echo out the variables because they are not working. I these values are to be used by the AWS cli program. I am testing the echo outside the script once it has ran.
    – Josh Kirby
    Aug 15 at 13:17










  • @RuiFRibeiro What do you mean?
    – Josh Kirby
    Aug 15 at 13:17






  • 1




    @JoshKirby, please edit your question to include a complete example of a script that exhibits the issue, along with a sample of how you run the script. sh -c 'export ID=foo; echo "$ID"' should work with whatever sh you have, so there's not enough information here to tell what the issue is.
    – ilkkachu
    Aug 15 at 13:21
















  • how are you trying to print the variables ... contents (not names)? After/outside the script, or within the script?
    – Jeff Schaller
    Aug 15 at 13:15











  • You have to source the script instead of running it.
    – Rui F Ribeiro
    Aug 15 at 13:16










  • I am trying to echo out the variables because they are not working. I these values are to be used by the AWS cli program. I am testing the echo outside the script once it has ran.
    – Josh Kirby
    Aug 15 at 13:17










  • @RuiFRibeiro What do you mean?
    – Josh Kirby
    Aug 15 at 13:17






  • 1




    @JoshKirby, please edit your question to include a complete example of a script that exhibits the issue, along with a sample of how you run the script. sh -c 'export ID=foo; echo "$ID"' should work with whatever sh you have, so there's not enough information here to tell what the issue is.
    – ilkkachu
    Aug 15 at 13:21















how are you trying to print the variables ... contents (not names)? After/outside the script, or within the script?
– Jeff Schaller
Aug 15 at 13:15





how are you trying to print the variables ... contents (not names)? After/outside the script, or within the script?
– Jeff Schaller
Aug 15 at 13:15













You have to source the script instead of running it.
– Rui F Ribeiro
Aug 15 at 13:16




You have to source the script instead of running it.
– Rui F Ribeiro
Aug 15 at 13:16












I am trying to echo out the variables because they are not working. I these values are to be used by the AWS cli program. I am testing the echo outside the script once it has ran.
– Josh Kirby
Aug 15 at 13:17




I am trying to echo out the variables because they are not working. I these values are to be used by the AWS cli program. I am testing the echo outside the script once it has ran.
– Josh Kirby
Aug 15 at 13:17












@RuiFRibeiro What do you mean?
– Josh Kirby
Aug 15 at 13:17




@RuiFRibeiro What do you mean?
– Josh Kirby
Aug 15 at 13:17




1




1




@JoshKirby, please edit your question to include a complete example of a script that exhibits the issue, along with a sample of how you run the script. sh -c 'export ID=foo; echo "$ID"' should work with whatever sh you have, so there's not enough information here to tell what the issue is.
– ilkkachu
Aug 15 at 13:21




@JoshKirby, please edit your question to include a complete example of a script that exhibits the issue, along with a sample of how you run the script. sh -c 'export ID=foo; echo "$ID"' should work with whatever sh you have, so there's not enough information here to tell what the issue is.
– ilkkachu
Aug 15 at 13:21










1 Answer
1






active

oldest

votes

















up vote
0
down vote














Superuser: what-is-the-difference-between-executing-a-bash-script-vs-sourcing-it



Short answer: sourcing will run the commands in the current shell process. executing will run the commands in a new shell process.




More info in the original question/answer



The below example shows the difference between running the script and sourceing it:



$ cat a.sh
export AWS_ACCESS_KEY_ID=key
export AWS_SECRET_ACCESS_KEY=secret_key
export AWS_DEFAULT_REGION=region
$ ./a.sh
$ echo $AWS_ACCESS_KEY_ID

$ source a.sh
$ echo $AWS_ACCESS_KEY_ID
key
$





share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote














    Superuser: what-is-the-difference-between-executing-a-bash-script-vs-sourcing-it



    Short answer: sourcing will run the commands in the current shell process. executing will run the commands in a new shell process.




    More info in the original question/answer



    The below example shows the difference between running the script and sourceing it:



    $ cat a.sh
    export AWS_ACCESS_KEY_ID=key
    export AWS_SECRET_ACCESS_KEY=secret_key
    export AWS_DEFAULT_REGION=region
    $ ./a.sh
    $ echo $AWS_ACCESS_KEY_ID

    $ source a.sh
    $ echo $AWS_ACCESS_KEY_ID
    key
    $





    share|improve this answer


























      up vote
      0
      down vote














      Superuser: what-is-the-difference-between-executing-a-bash-script-vs-sourcing-it



      Short answer: sourcing will run the commands in the current shell process. executing will run the commands in a new shell process.




      More info in the original question/answer



      The below example shows the difference between running the script and sourceing it:



      $ cat a.sh
      export AWS_ACCESS_KEY_ID=key
      export AWS_SECRET_ACCESS_KEY=secret_key
      export AWS_DEFAULT_REGION=region
      $ ./a.sh
      $ echo $AWS_ACCESS_KEY_ID

      $ source a.sh
      $ echo $AWS_ACCESS_KEY_ID
      key
      $





      share|improve this answer
























        up vote
        0
        down vote










        up vote
        0
        down vote










        Superuser: what-is-the-difference-between-executing-a-bash-script-vs-sourcing-it



        Short answer: sourcing will run the commands in the current shell process. executing will run the commands in a new shell process.




        More info in the original question/answer



        The below example shows the difference between running the script and sourceing it:



        $ cat a.sh
        export AWS_ACCESS_KEY_ID=key
        export AWS_SECRET_ACCESS_KEY=secret_key
        export AWS_DEFAULT_REGION=region
        $ ./a.sh
        $ echo $AWS_ACCESS_KEY_ID

        $ source a.sh
        $ echo $AWS_ACCESS_KEY_ID
        key
        $





        share|improve this answer















        Superuser: what-is-the-difference-between-executing-a-bash-script-vs-sourcing-it



        Short answer: sourcing will run the commands in the current shell process. executing will run the commands in a new shell process.




        More info in the original question/answer



        The below example shows the difference between running the script and sourceing it:



        $ cat a.sh
        export AWS_ACCESS_KEY_ID=key
        export AWS_SECRET_ACCESS_KEY=secret_key
        export AWS_DEFAULT_REGION=region
        $ ./a.sh
        $ echo $AWS_ACCESS_KEY_ID

        $ source a.sh
        $ echo $AWS_ACCESS_KEY_ID
        key
        $






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 15 at 13:27

























        answered Aug 15 at 13:21









        Yaron

        3,19421027




        3,19421027












            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay