From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 576 invoked from network); 4 Oct 1999 06:42:21 -0000 Received: from mail2.primenet.com.au (HELO primenet.com.au) (?GvQGbEZO6ASkDWlDVOUQFOmcH543ZeFJ?@203.24.36.6) by ns1.primenet.com.au with SMTP; 4 Oct 1999 06:42:21 -0000 Received: (qmail 24437 invoked from network); 4 Oct 1999 06:35:47 -0000 Received: from sunsite.auc.dk (130.225.51.30) by mail2.primenet.com.au with SMTP; 4 Oct 1999 06:35:47 -0000 Received: (qmail 19989 invoked by alias); 4 Oct 1999 06:30:06 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2656 Received: (qmail 19680 invoked from network); 4 Oct 1999 06:24:28 -0000 From: "Bart Schaefer" Message-Id: <991004062209.ZM952@candle.brasslantern.com> Date: Mon, 4 Oct 1999 06:22:09 +0000 In-Reply-To: Comments: In reply to Chris Hansen "Re: coproc tutorial (Re: questions)" (Oct 3, 10:21pm) References: X-Mailer: Z-Mail (5.0.0 30July97) To: Chris Hansen , zsh-users@sunsite.auc.dk Subject: Re: coproc tutorial (Re: questions) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Oct 3, 10:21pm, Chris Hansen wrote: } Subject: Re: coproc tutorial (Re: questions) } } What I was trying to do was write a script that would allow me to use } all of zsh's command line magic inside of other programs. I had some } nice results with bc, because it will take things from standard in. } I didn't do near as well with nslookup because it insists on taking } commands from the keyboard. Aha. Well, when I tried your script here, the problem with it was not nslookup reading from the keyboard; it was good old output buffering, just as I originally warned about ... nslookup gets the first query that your script sends it and computes the answer; but because standard *output* is not a terminal, it doesn't flush its buffer, and "read -pk" hangs the next time around your loop. This is typical stdio-library behavior: Output is block-buffered in 1024-byte (or 4096-byte or 8192-byte) chunks when the output is to a pipe or file, and line-buffered or unbuffered when to a terminal. By putting nslookup in the coprocess, you put it into block-buffered mode. You can avoid this by getting yourself a little program that opens a pty and runs nslookup there; "expect" can do it, and there are several others whose names I've forgotten. But in any case you need to do a lot more than just call "read" to get zsh's editor involved in all of this. See http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=1670 and good luck ... -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com