Re: BASH Scripting

"Pete Peterson" <[email protected]>
Newsgroups gmane.linux.redhat.release.enigma
Message-ID <[email protected]>

> From: Aaron Konstam <[email protected]>
> To: [email protected]
> Subject: Re: BASH Scripting
> 
> On Tue, Mar 18, 2003 at 05:17:08PM -0000, David Nithakorne wrote:
> > I am trying to set the value of SIDS in the following script to
> > something other than "". It seems that once out of the do/done block the
> > value od $SIDS reverts back to ""....why is this and how can I get $SIDS
> > to keep its new value opnce out of the do/done block. 
> > 
> > # !/bin/sh
> > SIDS=""
> > grep -v '^#' /etc/oratab | while read LINE
> > do
> >       ISID=`echo $LINE | cut -f1 -d:`
> >       OHOME=`echo $LINE | cut -f2 -d:`
> >       OBOWNER=`ls -l $OHOME/bin/sqlplus | awk '{print $3}'`
> >       SIDS=`echo "$SIDS $OBOWNER:$ISID"`
> >       echo "SIDS is $SIDS"
> > done
> >       echo SIDS is  $SIDS
> >       echo "OBOWNER is  $OBOWNER"
> > 
> > the /etc/oratab file is: - 
> > 
> > LD4U:/opt/oracle/product/9.2.0:Y 
> > oem:/opt/oracle/product/9.2.0:Y 
> > ld4udev:/opt/oracle/product/9.2.0:Y 
> > 
> > Thanks
> > 
> > David
> > 
> Just export $SIDS after it is defined.
> -------------------------------------------
> Aaron Konstam

How can that work?  The export allows referencing the variable
in the children of the defining process, but the child can't change the
environment of the parent.

-- 
    pete peterson
    Teradyne, Inc.; 7 Technology Park Drive; Westford, MA 01886-0033
    +1-978-589-7478 (Office); +1-978-589-2088 (FAX);
    [email protected] or [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.