Prompt for User Input and turn it into an environment variableEnvironment 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?

Why airport relocation isn't done gradually?

What happens when a metallic dragon and a chromatic dragon mate?

Email Account under attack (really) - anything I can do?

Does bootstrapped regression allow for inference?

If a centaur druid Wild Shapes into a Giant Elk, do their Charge features stack?

Can I legally use front facing blue light in the UK?

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

What is the command to reset a PC without deleting any files

Where to refill my bottle in India?

Is it legal to have the "// (c) 2019 John Smith" header in all files when there are hundreds of contributors?

Are cabin dividers used to "hide" the flex of the airplane?

Why do UK politicians seemingly ignore opinion polls on Brexit?

Is domain driven design an anti-SQL pattern?

What causes the sudden spool-up sound from an F-16 when enabling afterburner?

Is every set a filtered colimit of finite sets?

Is "plugging out" electronic devices an American expression?

Where else does the Shulchan Aruch quote an authority by name?

Doomsday-clock for my fantasy planet

How to manage monthly salary

Is there any use for defining additional entity types in a SOQL FROM clause?

Why is the design of haulage companies so “special”?

How could a lack of term limits lead to a "dictatorship?"

Can a planet have a different gravitational pull depending on its location in orbit around its sun?

Why doesn't a const reference extend the life of a temporary object passed via a function?



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;








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



enter image description here










share|improve this question







New contributor




GoatZero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 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

















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



enter image description here










share|improve this question







New contributor




GoatZero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 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













0












0








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



enter image description here










share|improve this question







New contributor




GoatZero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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



enter image description here







command-line bash environment-variables






share|improve this question







New contributor




GoatZero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




GoatZero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




GoatZero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 5 hours ago









GoatZeroGoatZero

1011




1011




New contributor




GoatZero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





GoatZero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






GoatZero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 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





    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










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.









draft saved

draft discarded


















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.









draft saved

draft discarded


















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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Möglingen Índice Localización Historia Demografía Referencias Enlaces externos Menú de navegación48°53′18″N 9°07′45″E / 48.888333333333, 9.129166666666748°53′18″N 9°07′45″E / 48.888333333333, 9.1291666666667Sitio web oficial Mapa de Möglingen«Gemeinden in Deutschland nach Fläche, Bevölkerung und Postleitzahl am 30.09.2016»Möglingen

Virtualbox - Configuration error: Querying “UUID” failed (VERR_CFGM_VALUE_NOT_FOUND)“VERR_SUPLIB_WORLD_WRITABLE” error when trying to installing OS in virtualboxVirtual Box Kernel errorFailed to open a seesion for the virtual machineFailed to open a session for the virtual machineUbuntu 14.04 LTS Virtualbox errorcan't use VM VirtualBoxusing virtualboxI can't run Linux-64 Bit on VirtualBoxUnable to insert the virtual optical disk (VBoxguestaddition) in virtual machine for ubuntu server in win 10VirtuaBox in Ubuntu 18.04 Issues with Win10.ISO Installation

Torre de la Isleta Índice Véase también Referencias Bibliografía Enlaces externos Menú de navegación38°25′58″N 0°23′02″O / 38.43277778, -0.3838888938°25′58″N 0°23′02″O / 38.43277778, -0.38388889Torre de la Illeta de l’Horta o Torre Saleta. Base de datos de bienes inmuebles. Patrimonio Cultural. Secretaría de Estado de CulturaFicha BIC Torre de la Illeta de l’Horta. Dirección General de Patrimonio Cultural. Generalitat ValencianaLugares de interés. Ayuntamiento del CampelloTorre de la Isleta en CastillosNet.org