Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-23-2005, 01:33 AM   #1
Senior Member
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Rep: Reputation: 45
bash programming

Hi ...
I want to create ascript that can read and modify a environmental variable... Cn u help me a little?
For example
sh myscript
a has value 2
changing a
a has value 3

After the script has stopeed executing i want to read the new value of a .... Any good suggestion? Thx a lot
Old 07-23-2005, 01:52 AM   #2
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 125Reputation: 125
You cannot do this in the way you have described. A script can only change variables in its own environment, which are then inherited by children, but leave parents unaffected. The closest you can get is this:
export a=NEW_VALUE
$ source
You can also use a single '.' (dot) as a shortcut for source, like so:
$ .
Old 07-23-2005, 01:52 AM   #3
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
want to create ascript that can read and modify a environmental variable... Cn u help me a little?
For example
What have you tried so far?



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
Bash programming winterhunter Linux - Newbie 6 11-26-2007 08:14 AM
Bash Programming moodupani Programming 1 08-31-2005 07:50 PM
bash programming drisay Programming 6 12-20-2004 10:09 AM
bash programming cpukiller Linux - Newbie 1 11-04-2003 07:45 PM
bash programming bulliver Programming 2 04-05-2003 10:30 PM > Forums > Non-*NIX Forums > Programming

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

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