how to source a file in a script

  • Follow


Hi,

First, can someone explain what it means to "source a file"?  I'm new to an
application on a solaris server that one of the steps to compile oracle
forms is
to source a file via the command:  . /path/filetosource.sh

Second, I want to incorporate this "sourcing" into a script file I can run
so I
can make it easier to compile the oracle forms.  How can I do it?  If I put
.. /path/filetosource.sh in the script, it doesn't seem to do it.

Thanks,

Tim


0
Reply web 9/10/2003 3:51:09 PM

"web guy" <web-guy01@comcast.net> writes:

> First, can someone explain what it means to "source a file"?  I'm new to an
> application on a solaris server that one of the steps to compile oracle
> forms is
> to source a file via the command:  . /path/filetosource.sh

When the shell sources a file, it executes each line of the file as if
it was typed on the command line, or inserted into the script it's
currently processing.  It is commonly used to set environment
variables.

> Second, I want to incorporate this "sourcing" into a script file I
> can run so I can make it easier to compile the oracle forms.  How
> can I do it?  If I put . /path/filetosource.sh in the script, it
> doesn't seem to do it.

That should work.  Try it out with some simple test cases.

-- 
M�ns Rullg�rd
mru@users.sf.net
0
Reply mru 9/10/2003 4:02:28 PM



M�ns Rullg�rd wrote:
> "web guy" <web-guy01@comcast.net> writes:
> 
> 
>>First, can someone explain what it means to "source a file"?  I'm new to an
>>application on a solaris server that one of the steps to compile oracle
>>forms is
>>to source a file via the command:  . /path/filetosource.sh
> 
> 
> When the shell sources a file, it executes each line of the file as if
> it was typed on the command line, or inserted into the script it's
> currently processing.  It is commonly used to set environment
> variables.
> 
> 
>>Second, I want to incorporate this "sourcing" into a script file I
>>can run so I can make it easier to compile the oracle forms.  How
>>can I do it?  If I put . /path/filetosource.sh in the script, it
>>doesn't seem to do it.
> 
> 
> That should work.  Try it out with some simple test cases.
> 

If you put a source into a script, it will not affect the
parent shell unless the script itself is sourced.  Otherwise,
a script is run in a sub-shell and all source information is lost
when the sub-shell exits.

--

Fletcher Glenn

0
Reply Fletcher 9/10/2003 4:32:24 PM

Thank you both for the info.  The second explanation about
the subshell is why I didn't think it was working in the script.

Thanks.

"Fletcher Glenn" <fletcher@removethisfoglight.com> wrote in message
news:3F5F5224.7050104@removethisfoglight.com...
>
>
> M�ns Rullg�rd wrote:
> > "web guy" <web-guy01@comcast.net> writes:
> >
> >
> >>First, can someone explain what it means to "source a file"?  I'm new to
an
> >>application on a solaris server that one of the steps to compile oracle
> >>forms is
> >>to source a file via the command:  . /path/filetosource.sh
> >
> >
> > When the shell sources a file, it executes each line of the file as if
> > it was typed on the command line, or inserted into the script it's
> > currently processing.  It is commonly used to set environment
> > variables.
> >
> >
> >>Second, I want to incorporate this "sourcing" into a script file I
> >>can run so I can make it easier to compile the oracle forms.  How
> >>can I do it?  If I put . /path/filetosource.sh in the script, it
> >>doesn't seem to do it.
> >
> >
> > That should work.  Try it out with some simple test cases.
> >
>
> If you put a source into a script, it will not affect the
> parent shell unless the script itself is sourced.  Otherwise,
> a script is run in a sub-shell and all source information is lost
> when the sub-shell exits.
>
> --
>
> Fletcher Glenn
>


0
Reply web 9/10/2003 7:10:41 PM

3 Replies
443 Views

(page loaded in 0.047 seconds)

Similiar Articles:













7/23/2012 6:42:42 AM


Reply: