LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 10-26-2005, 03:07 PM   #1
joehansen12
LQ Newbie
 
Registered: Oct 2005
Posts: 4

Rep: Reputation: 0
Unable to export variables declared in a script


hi all,

How do I declare/initialize an environment variable in a script?

i have a file named set-abcd.sh.

*** setabcd.sh *****
MESS=hello ; export MESS
echo $MESS
******************

$ MESS=yahoo ; export MESS
$ echo $MESS
yahoo
$ ./set-abcd.sh
hello
$ echo $MESS
yahoo

Please help!

thanks,
Joe
 
Old 10-26-2005, 03:09 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Works as designed. What you want to do isn't to RUN
the script, but instead source it.

E.g.
Code:
. my_script.sh
or
Code:
source my_script.sh

Cheers,
Tink
 
Old 10-26-2005, 03:25 PM   #3
joehansen12
LQ Newbie
 
Registered: Oct 2005
Posts: 4

Original Poster
Rep: Reputation: 0
thanks tinkster! source did the trick!
 
  


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
why do we have to export variables? learnfast Linux - Newbie 2 05-27-2005 09:27 AM
export variables alaios Linux - General 3 12-04-2004 08:33 AM
keep my export variables captain-cat Linux - Newbie 9 06-23-2004 06:22 AM
export variables radnix Linux - General 2 04-28-2004 07:52 PM
Why wont my variables export? suerevans Linux - Newbie 5 04-05-2004 04:46 AM


All times are GMT -5. The time now is 08:41 AM.

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