From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12328 invoked from network); 27 Aug 1999 10:56:42 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 27 Aug 1999 10:56:42 -0000 Received: (qmail 17877 invoked by alias); 27 Aug 1999 10:56:14 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2525 Received: (qmail 17870 invoked from network); 27 Aug 1999 10:56:13 -0000 Sender: airwin@inf.bme.hu To: zsh-users@sunsite.auc.dk Subject: Re: Perl like select()? References: From: Nemeth Ervin Date: 27 Aug 1999 12:56:09 +0200 In-Reply-To: Zefram's message of "Wed, 25 Aug 1999 17:16:04 +0100 (BST)" Message-ID: User-Agent: Gnus/5.070095 (Pterodactyl Gnus v0.95) Emacs/20.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Hi! >>>>> Zefram writes: > Josh Howard wrote: >> Is there any way, in a script, to use a "Perl-like" select() to >> associate stdout with a particular file, before the execution of the >> rest of the script? > exec > file > permanently redirects stdout. Any redirection can be used this way. If you want to keep std{in,out,err}, you can also use a new descriptor. Example: # -*- sh -*- local i file file=~/.ssh/known_hosts reply=() [[ -r $file ]] || return exec 5< $file while read -u5 -A i do reply=($reply $i[1]) done exec 5<&- -- ____ ____________________________________________________ /____| NEMETH, ERVIN |____________________________________________________| // < airwin @ inf.bme.hu > http://www.inf.bme.hu/~airwin || || "Nonsense. All you have to do is say 'Engage'" || -- Patrick Stewart about warp theory