Prompt for User Input and turn it into an environment variableEnvironment variable vs Shell variable, what's...
Is there a way to make member function NOT callable from constructor?
Is there any use for defining additional entity types in a SOQL FROM clause?
What does "enim et" mean?
Is it wise to hold on to stock that has plummeted and then stabilized?
Is this food a bread or a loaf?
Is it wise to focus on putting odd beats on left when playing double bass drums?
How to make payment on the internet without leaving a money trail?
How could a lack of term limits lead to a "dictatorship?"
How can I plot a Farey diagram?
Lied on resume at previous job
What happens when a metallic dragon and a chromatic dragon mate?
How would photo IDs work for shapeshifters?
Is there a familial term for apples and pears?
Is domain driven design an anti-SQL pattern?
COUNT(*) or MAX(id) - which is faster?
How to manage monthly salary
Can a planet have a different gravitational pull depending on its location in orbit around its sun?
Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?
How to move the player while also allowing forces to affect it
What is it called when one voice type sings a 'solo'?
Domain expired, GoDaddy holds it and is asking more money
What does it exactly mean if a random variable follows a distribution
Why is my log file so massive? 22gb. I am running log backups
Re-submission of rejected manuscript without informing co-authors
Prompt for User Input and turn it into an environment variable
Environment variable vs Shell variable, what's the difference?Setting global environment variable for everyoneEnvironment Variable - how does properly set them (bashrc or profile)Why can't my user see environment variable?environment variable not workingEnvironment Variable for PYTHONPATHcapturing current user in variable and inserting it into fileANDROID_HOME environment variableEnvironment variableHow to find the source definition of an environment variable?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'm trying to make a script that gives me my current public IP, and asks the user for a new IP that should be declared as an environment variable for ubuntu, however even tho the MASTER variable is working as intended the SLAVE one isn't. here's a minimum sample of my script
#!/bin/bash
echo $SHELLOPTS
set -o allexport #All variables are auto set to export
MASTER=`ip addr | grep inet | grep 10. | tail -1 | sed 's/^ *//g' | cut -d ' ' -f 2 | sed 's//.*$//g'`
echo Master IP is: $MASTER
echo Insert the new IP:
read input
SLAVE=$input
echo Master IP is: $MASTER
echo Slave IP is: $SLAVE
Even tho the variable is actually printed, it cannot be reused more than once as an environment variable, I have been looking around this problem with no luck, any help will be really appreciated
command-line bash environment-variables
New contributor
add a comment |
I'm trying to make a script that gives me my current public IP, and asks the user for a new IP that should be declared as an environment variable for ubuntu, however even tho the MASTER variable is working as intended the SLAVE one isn't. here's a minimum sample of my script
#!/bin/bash
echo $SHELLOPTS
set -o allexport #All variables are auto set to export
MASTER=`ip addr | grep inet | grep 10. | tail -1 | sed 's/^ *//g' | cut -d ' ' -f 2 | sed 's//.*$//g'`
echo Master IP is: $MASTER
echo Insert the new IP:
read input
SLAVE=$input
echo Master IP is: $MASTER
echo Slave IP is: $SLAVE
Even tho the variable is actually printed, it cannot be reused more than once as an environment variable, I have been looking around this problem with no luck, any help will be really appreciated
command-line bash environment-variables
New contributor
3
If you want the shell variables to continue to exist after the script has finished, you need to source the script, like. scriptname
. If you execute it rather than source it, it is run in a subshell and all environmental changes are lost when the subshell exits.
– John1024
4 hours ago
Or dont use a script at all but a function defined in .bashrc
– Sergiy Kolodyazhnyy
4 hours ago
add a comment |
I'm trying to make a script that gives me my current public IP, and asks the user for a new IP that should be declared as an environment variable for ubuntu, however even tho the MASTER variable is working as intended the SLAVE one isn't. here's a minimum sample of my script
#!/bin/bash
echo $SHELLOPTS
set -o allexport #All variables are auto set to export
MASTER=`ip addr | grep inet | grep 10. | tail -1 | sed 's/^ *//g' | cut -d ' ' -f 2 | sed 's//.*$//g'`
echo Master IP is: $MASTER
echo Insert the new IP:
read input
SLAVE=$input
echo Master IP is: $MASTER
echo Slave IP is: $SLAVE
Even tho the variable is actually printed, it cannot be reused more than once as an environment variable, I have been looking around this problem with no luck, any help will be really appreciated
command-line bash environment-variables
New contributor
I'm trying to make a script that gives me my current public IP, and asks the user for a new IP that should be declared as an environment variable for ubuntu, however even tho the MASTER variable is working as intended the SLAVE one isn't. here's a minimum sample of my script
#!/bin/bash
echo $SHELLOPTS
set -o allexport #All variables are auto set to export
MASTER=`ip addr | grep inet | grep 10. | tail -1 | sed 's/^ *//g' | cut -d ' ' -f 2 | sed 's//.*$//g'`
echo Master IP is: $MASTER
echo Insert the new IP:
read input
SLAVE=$input
echo Master IP is: $MASTER
echo Slave IP is: $SLAVE
Even tho the variable is actually printed, it cannot be reused more than once as an environment variable, I have been looking around this problem with no luck, any help will be really appreciated
command-line bash environment-variables
command-line bash environment-variables
New contributor
New contributor
New contributor
asked 5 hours ago
GoatZeroGoatZero
1011
1011
New contributor
New contributor
3
If you want the shell variables to continue to exist after the script has finished, you need to source the script, like. scriptname
. If you execute it rather than source it, it is run in a subshell and all environmental changes are lost when the subshell exits.
– John1024
4 hours ago
Or dont use a script at all but a function defined in .bashrc
– Sergiy Kolodyazhnyy
4 hours ago
add a comment |
3
If you want the shell variables to continue to exist after the script has finished, you need to source the script, like. scriptname
. If you execute it rather than source it, it is run in a subshell and all environmental changes are lost when the subshell exits.
– John1024
4 hours ago
Or dont use a script at all but a function defined in .bashrc
– Sergiy Kolodyazhnyy
4 hours ago
3
3
If you want the shell variables to continue to exist after the script has finished, you need to source the script, like
. scriptname
. If you execute it rather than source it, it is run in a subshell and all environmental changes are lost when the subshell exits.– John1024
4 hours ago
If you want the shell variables to continue to exist after the script has finished, you need to source the script, like
. scriptname
. If you execute it rather than source it, it is run in a subshell and all environmental changes are lost when the subshell exits.– John1024
4 hours ago
Or dont use a script at all but a function defined in .bashrc
– Sergiy Kolodyazhnyy
4 hours ago
Or dont use a script at all but a function defined in .bashrc
– Sergiy Kolodyazhnyy
4 hours ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
GoatZero is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1132286%2fprompt-for-user-input-and-turn-it-into-an-environment-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
GoatZero is a new contributor. Be nice, and check out our Code of Conduct.
GoatZero is a new contributor. Be nice, and check out our Code of Conduct.
GoatZero is a new contributor. Be nice, and check out our Code of Conduct.
GoatZero is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1132286%2fprompt-for-user-input-and-turn-it-into-an-environment-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
If you want the shell variables to continue to exist after the script has finished, you need to source the script, like
. scriptname
. If you execute it rather than source it, it is run in a subshell and all environmental changes are lost when the subshell exits.– John1024
4 hours ago
Or dont use a script at all but a function defined in .bashrc
– Sergiy Kolodyazhnyy
4 hours ago