From owner-freebsd-hackers Fri Sep 26 10:25:19 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id KAA17183 for hackers-outgoing; Fri, 26 Sep 1997 10:25:19 -0700 (PDT) Received: from canario.fiscodata (tty816.netpar.com.br [200.255.244.88] (may be forged)) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id KAA17176 for ; Fri, 26 Sep 1997 10:25:13 -0700 (PDT) Received: from canario.fiscodata (canario.fiscodata [192.168.0.1]) by canario.fiscodata (8.8.7/8.8.5) with SMTP id OAA09134; Fri, 26 Sep 1997 14:23:46 GMT Date: Fri, 26 Sep 1997 14:23:46 +0000 (GMT) From: Paulo Cesar Pereira de Andrade X-Sender: paulo@canario.fiscodata Reply-To: Paulo Cesar Pereira de Andrade To: Jon Hamilton cc: Terry Lambert , hackers@FreeBSD.ORG Subject: Re: Timeout for sh(1) 'read' ?? In-Reply-To: <199709261259.FAA03276@hub.freebsd.org> Message-ID: X-FreeBSD: The Operating System X-Window-System: The Windowing System MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Fri, 26 Sep 1997, Jon Hamilton wrote: > In message <199709261159.EAA20125@usr09.primenet.com>, Terry Lambert writes: > } > Hiho folks, a question for the sh(1) studs amongst you : > } > > } > - I want to prompt for input using 'read', and have the read return in > } > some fashion after a timeout. > } > > } > I'd like to do this just using sh, and I'm not too fussed about how > } > hairy it is. Any ideas? > } > > } > (If sh has to be modified to achieve this, would it be a useful thing > } > to bring back?) > } > } Write a "timedread" program that returns "TIMEOUT" or "USERDATA xxxxx" > } and do "timedread | read x" and look at the front of x? 8-) 8-). > > Which will of course execute in a subshell because of the pipe and wind > up doing you no good. > > You can do this kind of thing with background processes and trap, but > it's not what you'd call pretty, and even that isn't as straightforward > as it might sound. What about dd if=/dev/stdin of=/dev/stdout skip=0 | read x I have been reading this list for time enough to know that Terry loves it. :) -- Paulo Cesar Pereira de Andrade - mailto:paulo@netpar.com.br FreeBSD - http://www.freebsd.org XFree86 - http://www.xfree86.org