LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   get all vars and set locally in script (https://www.linuxquestions.org/questions/linux-newbie-8/get-all-vars-and-set-locally-in-script-868511/)

tank junior 03-14-2011 12:00 PM

get all vars and set locally in script
 
Hi,
I am new to linux and need to do this in a script.
1. Get all the vars (env command)
2. Set them locally (name, value pair) in script using loop iteration.
Pseudo code
Code:

vars = 'env'
for name, value in vars:
    export name=value


corp769 03-14-2011 12:06 PM

Can I ask why you would want to do this, when the "vars" are already environmentally set? This makes no sense to me whatsoever...

Edit - TB0ne's post under mine sounds clearer, for as I don't have as good writing skills, as you can tell. That being said, we now NEED to know what you are trying to accomplish....

Josh

TB0ne 03-14-2011 12:09 PM

Quote:

Originally Posted by tank junior (Post 4290405)
Hi,
I am new to linux and need to do this in a script.
1. Get all the vars (env command)
2. Set them locally (name, value pair) in script using loop iteration.
Pseudo code
Code:

vars = 'env'
for name, value in vars:
    export name=value


Ok...we now know what you WANT to do. Now show us what you've DONE. We'll be glad to help, but we're not going to write the script for you. You know about the ENV command, obviously, which can read them, but your second point makes no sense. You say you want to 'set them locally'...well, they're obviously ALREADY set, hence you being able to read them with the ENV command.

Please clarify the question, and post the code you've already written. There are also many bash scripting tutorials you can find on the Internet, which should be able to help you. And is this homework???


All times are GMT -5. The time now is 11:32 PM.