Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Feb 2007 04:34:35 -0500
From:      "Dak Ghatikachalam" <dghatikachalam@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Korn shell script Question
Message-ID:  <ba29b9b40702020134h63c8dcfdpba331cd35eb80672@mail.gmail.com>
In-Reply-To: <20070131202202.GB49580@fw.home>
References:  <ba29b9b40701311043u74a60268y390c32b5579fdd1d@mail.gmail.com> <20070131190658.GA49580@fw.home> <ba29b9b40701311127q1600c115k5eb0f69da0733ef6@mail.gmail.com> <20070131202202.GB49580@fw.home>

next in thread | previous in thread | raw e-mail | index | archive | help
On 1/31/07, kris <bsdaemon@comcast.net> wrote:
>
> On Wed, Jan 31, 2007 at 02:27:24PM -0500, Dak Ghatikachalam wrote:
> >Thanks a lot , I test ran it. This is great
>
> No problem. I should add that if this is to be part of a long running
> script, you should close the co-process (the while-loop running cat),
> with something like:
>
> exec 5<&p
> exec 5<&-
>


I did not really understand this part of the email

Did you mean that I should

{ while cat /tmp/availdest.$$; do false; done } |&
exec 5<&p

{ while cat file1.txt; do false; done } |&

cat file2.txt |
while read file_b
do
        read -p file_a
        echo $file_b $file_a
done >file3.txt

exec 5<&-

should I do something like this?  will this work ?


-------------

WHen I put this code in large part of the code,  several times it speews out
error like "coprocess already exists"

here is excerpts of the code.

{ while cat /tmp/availdest.$$; do false; done } |&

cat  ${RESTORELINKDIR}/rman_restore_dir/${RESTORENAM}|awk '/DATAFILE/ {
print $0
 }'|tr -d ' '|
while read file_b
do
        read -p file_a
        echo $file_b "|" $file_a
done >/tmp/dataf.$$

prev_used="none";
typeset -i initial_cntr=0;
rm -rf /tmp/spaceiss.$$ /tmp/reprocesses.$$ /tmp/availspace.$$
for dbfilerec in `cat  /tmp/dataf.$$|awk '/DATAFILE/ { print $0 }'|tr -d ' '
`
do
                dest_tst=`echo $dbfilerec|awk -F"|" '{print $5}'`
                DISK_MB=`df -k ${dest_tst} | tail -1|awk '{print
int($4/1024)}'`
                echo "Available Disk space = ${DISK_MB} MB"
                Fil_size=`echo $dbfilerec |awk -F"|" '{print int($4)}'`
                echo "Filesize needed  = ${Fil_size} MB"

                         if [ ${DISK_MB} -gt ${Fil_size} ]
FIL_NO=`echo $dbfilerec |awk -F"|" '{print int($2)}'`
                                TARGET_DIR=`echo
"$dest_tst/$DEST_ORA_SID"|tr -d ' '`
                                mkdir -p  ${TARGET_DIR}
                                if [ $? != 0 ]
                                then
                                        SendNotification "For Database
${ORACLE_SID} RMAN backup $RESTOREPRCSLOGDIR Could not be created for
backup"
                                fi
                                strip_dir=`echo $dbfilerec |awk -F"|"
'{print $3}'`
                                TARGET_FILE=`basename $strip_dir|tr -d ' '`
                                perform_actual_restore;
                                prev_used=`echo $dest_tst`

                        fi
                         if [ ${DISK_MB} -le ${Fil_size} ]
                         then
                                echo $dbfilerec|awk -F"|" '{print $5}'
>/tmp/spaceiss.$$
                                echo $dbfilerec|awk -F"|"  '/DATAFILE/ {OFS
= "|";$5=""; print}'   >/tmp/reprocesses.$$
                         fi
done

if [ -s /tmp/reprocesses.$$ ]
then
        diff /tmp/availdest.$$ /tmp/spaceiss.$$|awk -F"<" '{print $2}'|awk
NF|tr -d ' '>/tmp/availspace.$$
fi
if [ -s /tmp/availspace.$$ ]
then



 but one thing I noticed  was that



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ba29b9b40702020134h63c8dcfdpba331cd35eb80672>