Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: parameters disappear - newbie needs help

Re: parameters disappear - newbie needs help

From: Nuno Souto <nsouto_at_nsw.bigpond.net.au.nospam>
Date: Wed, 06 Oct 1999 12:47:18 GMT
Message-ID: <37fb3f67.12301395@news-server>


On Wed, 06 Oct 1999 11:42:04 GMT, Bob Hartung <rwhartung_at_home.com> wrote:

>
> PARAMETER=CONTENTS
> export PARAMETER
> echo PARAMETER $PARAMETER
>
>When I run the script all looks well, but after the script terminated
>if I do a
> echo PARAMETER
>
>from the command line no value is returned.
>

If you are running the sh() or ksh() shells (and it looks like you are using at least one of these), the behaviour is correct. Environment variables set in a script are "visible" only for the execution of that script. And if they are exported, they are "visible" to that script AND any other scripts that may be executed from within your script.

In order for the environment variables to be propagated (copied) to your interactive shell or calling script (as opposed to the called scripts), you need to execute the script with a special syntax.

In both sh() and ksh(), and assuming your script is called "mysc.sh", do this:

prompt>. mysc.sh<CR>

Note: this is "prompt"followed by "dot", followed by a single "space", followed by the script name, followed by the Enter key.

What this does is to tell your called script (and associated shell) to copy into the caller's environment any variables that maybe exported in the called script. What really happens is slightly more complex than this, but for the time being this should sort you out.

HTH Cheers
Nuno Souto
nsouto_at_nsw.bigpond.net.au.nospam
http://www.users.bigpond.net.au/the_Den/index.html Received on Wed Oct 06 1999 - 07:47:18 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US