LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-14-2011, 01:00 PM   #1
tank junior
Member
 
Registered: Apr 2010
Posts: 42

Rep: Reputation: 0
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
 
Old 03-14-2011, 01:06 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
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

Last edited by corp769; 03-14-2011 at 01:23 PM.
 
Old 03-14-2011, 01:09 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,343

Rep: Reputation: 3906Reputation: 3906Reputation: 3906Reputation: 3906Reputation: 3906Reputation: 3906Reputation: 3906Reputation: 3906Reputation: 3906Reputation: 3906Reputation: 3906
Quote:
Originally Posted by tank junior View Post
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???
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'set' command to output vars without values leniviy Linux - General 4 09-03-2010 11:41 AM
Case statements and vars for bash script geech Programming 1 01-09-2009 05:49 PM
shell script backticks and vars? SheldonPlankton Programming 4 07-21-2004 12:29 PM
Python - Set vars and loop over lines in file jnoller Programming 6 02-07-2004 11:32 AM
how to set environment vars at GNOME terminal startup ? janisj Linux - General 8 07-30-2003 07:35 PM


All times are GMT -5. The time now is 10:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration