LinuxQuestions.org
Visit Jeremy's Blog.
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-31-2004, 06:56 PM   #1
suerevans
LQ Newbie
 
Registered: Mar 2004
Posts: 6

Rep: Reputation: 0
Unhappy Why wont my variables export?


Im confused. My variables wont export!

Im trying to set up a korn shell profile using a variety of files. On other unix systems this works fine, and Im sure it should on linux (RH9 server install incidentally).

Intially, the .profile is called (or .kshrc whichever you prefer).

Two variables are set and then a file - ora.prof is called. When the control returns to this script, a couple of more variables are also set.

ora.prof then calls another file - btch.prof and then sets a couple of alias's when it returns

btch.prof calls use.prof and also sets some variables when it returns

Finally, use.prof calls the final script - ora.env which also sets a whole load of variables and asks for user input etc.

Each file sets the variables within itself - but they do not translate back into the global environment. As soon as the script setting them finishes the variables unbind and the values are lost.

My understanding is that export should send these settings out into the wider environment. So I should end up with about 15 variables set and 3 alias's. Instead I only get the ones specified in .profile.

Has anyone come across this before? Ive been on it for hours and am getting no where :-(

Thanks!
Sue
 
Old 03-31-2004, 08:22 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
Hi, and welcome to LQ!

Well, the difference is whether you run
or source a script, I guess ... when you
run it, it spawns a new shell, and the
scope of any exported variable is the
lifetime of that sub-shell.

But I'm not an expert on korn-shell,
this may be completely different from
bash :}


Cheers,
Tink

Last edited by Tinkster; 03-31-2004 at 08:23 PM.
 
Old 04-02-2004, 07:36 AM   #3
suerevans
LQ Newbie
 
Registered: Mar 2004
Posts: 6

Original Poster
Rep: Reputation: 0
Smile worked it out...

Well - turns out that there was a combination of issues (and I couldnt get it to work with bash either so I guess this may be relevant for both shells)

The first change I ended up making was downloading ksh from the at&t website - it would appear that the version of ksh on the RH9 cd's is a cut down one and misses some of the required commands.

The second was that I had removed the '. ' bit from the call other script lines (so I had /usr/local/oracle/ora.prof instead of . /usr/local/oracle/ora.prof)

once I had put the '. ' bit back in, the variables became global and were passing back correctly.

So, I guess the '. ' bit must prompt the execution of the scripts to be global where as just listing the name of the script only tells it to run and remain local to it.

Thanks for replying :-)
Sue
 
Old 04-02-2004, 08:00 AM   #4
fsbooks
Member
 
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 457

Rep: Reputation: 41
Just to confirm, the '. ' "sources" the script in the current shell, and does not "run" it in a new shell.
 
Old 04-02-2004, 08:08 AM   #5
suerevans
LQ Newbie
 
Registered: Mar 2004
Posts: 6

Original Poster
Rep: Reputation: 0
Ahhhhh that explains it then :-) I was still rather confused as to what it actually meant

Thanks !
 
Old 04-05-2004, 04:46 AM   #6
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
One is glad to have been of service :)


Thanks to fsbooks for clarifying the the sourcing bit ;)




Cheers,
Tink
 
  


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
really easy question: why won't my environment variables export digitized_funk Linux - Newbie 3 10-22-2003 06:22 AM


All times are GMT -5. The time now is 05:03 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