From owner-freebsd-questions@FreeBSD.ORG Fri Feb 2 09:34:38 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BE29816A401 for ; Fri, 2 Feb 2007 09:34:38 +0000 (UTC) (envelope-from dghatikachalam@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.236]) by mx1.freebsd.org (Postfix) with ESMTP id 7BAA913C4B3 for ; Fri, 2 Feb 2007 09:34:36 +0000 (UTC) (envelope-from dghatikachalam@gmail.com) Received: by wx-out-0506.google.com with SMTP id s18so815473wxc for ; Fri, 02 Feb 2007 01:34:36 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=bngugEqLXn7HOOL1DYSNf+O5fzcXHlolUkkzdBkz2HekEsz/g1jTcMSdEE4/neULibPP+f0DcQ9SHl6xCjGJe4qGYdyawcnbhXJQP70kAaIjzH8HdefW35IkQGslfXnMaIy4aCaEyYnskD9BWgP+LQufsDtC2EfEjdINNUiGWyI= Received: by 10.70.75.14 with SMTP id x14mr5719406wxa.1170408875946; Fri, 02 Feb 2007 01:34:35 -0800 (PST) Received: by 10.70.52.12 with HTTP; Fri, 2 Feb 2007 01:34:35 -0800 (PST) Message-ID: Date: Fri, 2 Feb 2007 04:34:35 -0500 From: "Dak Ghatikachalam" To: freebsd-questions@freebsd.org In-Reply-To: <20070131202202.GB49580@fw.home> MIME-Version: 1.0 References: <20070131190658.GA49580@fw.home> <20070131202202.GB49580@fw.home> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: Korn shell script Question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Feb 2007 09:34:38 -0000 On 1/31/07, kris 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