Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Feb 2007 13:50:47 -0500
From:      Kris Maglione <bsdaemon@comcast.net>
To:        Dak Ghatikachalam <dghatikachalam@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Korn shell script Question
Message-ID:  <20070202185046.GA3073@fw.home>
In-Reply-To: <ba29b9b40702020810v6e371cb3i92a3504c6285b790@mail.gmail.com>
References:  <ba29b9b40701311043u74a60268y390c32b5579fdd1d@mail.gmail.com> <20070131190658.GA49580@fw.home> <ba29b9b40701311127q1600c115k5eb0f69da0733ef6@mail.gmail.com> <20070131202202.GB49580@fw.home> <ba29b9b40702020810v6e371cb3i92a3504c6285b790@mail.gmail.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Fri, Feb 02, 2007 at 11:10:02AM -0500, Dak Ghatikachalam wrote:
>{ while cat /tmp/availspace.$$; do false; done } |&
>exec 5<&p
>cat  /tmp/reprocesses.$$|awk '/DATAFILE/ { print $0 }'|tr -d ' '|
>while read file_b
>do
>        read -u5 file_a
>        echo $file_b $file_a
>done >/tmp/reprocessrecset.$$
>
>exec 5<&-
>
>this what you meant ?

It doesn't matter where you put the redirects, so long as they're in 
order and you wind up closing the coprocess's standard output so that it 
exits. It's more a matter of style and taste than anything. Here are 
some more options if you're interested:

As long as you haven't started any other background jobs, this would 
work in place of the final 'exec 5<&-':
kill -INT %+

Or, after you start the coprocess, you can store its PID, and kill that 
later:
copid=$!
...
kill -INT $copid

Again, it's a matter of style and taste. If it's not to be part of a 
long running script, though, don't even worry about it.



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20070202185046.GA3073>