Bash environment variables not setting [duplicate]
Clash 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>
linux aws
marked as duplicate by Kusalananda
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.
 |Â
show 3 more comments
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>
linux aws
marked as duplicate by Kusalananda
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 whateversh
you have, so there's not enough information here to tell what the issue is.
â ilkkachu
Aug 15 at 13:21
 |Â
show 3 more comments
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>
linux aws
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
linux aws
asked Aug 15 at 13:14
Josh Kirby
1
1
marked as duplicate by Kusalananda
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
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 whateversh
you have, so there's not enough information here to tell what the issue is.
â ilkkachu
Aug 15 at 13:21
 |Â
show 3 more comments
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 whateversh
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
 |Â
show 3 more comments
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 source
ing 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
$
add a comment |Â
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 source
ing 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
$
add a comment |Â
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 source
ing 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
$
add a comment |Â
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 source
ing 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
$
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 source
ing 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
$
edited Aug 15 at 13:27
answered Aug 15 at 13:21
Yaron
3,19421027
3,19421027
add a comment |Â
add a comment |Â
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 whateversh
you have, so there's not enough information here to tell what the issue is.â ilkkachu
Aug 15 at 13:21