From owner-freebsd-questions Tue Apr 25 13:43:36 2000 Delivered-To: freebsd-questions@freebsd.org Received: from supai.oit.umass.edu (mailhub.oit.umass.edu [128.119.175.6]) by hub.freebsd.org (Postfix) with ESMTP id B7DE737B69A for ; Tue, 25 Apr 2000 13:43:32 -0700 (PDT) (envelope-from gpav@som.umass.edu) Received: from CONVERSION-DAEMON by supai.oit.umass.edu (PMDF V5.2-32 #38130) id <0FTL00K01AUUTO@supai.oit.umass.edu> for freebsd-questions@FreeBSD.ORG; Tue, 25 Apr 2000 16:42:31 -0400 (EDT) Received: from yolen.oit.umass.edu (yolen.oit.umass.edu [128.119.166.35]) by supai.oit.umass.edu (PMDF V5.2-32 #38130) with ESMTP id <0FTL00JDSAUUS4@supai.oit.umass.edu>; Tue, 25 Apr 2000 16:42:30 -0400 (EDT) Received: from localhost (gp@localhost) by yolen.oit.umass.edu (8.9.3/8.9.3) with ESMTP id QAA11182; Tue, 25 Apr 2000 16:43:16 -0400 (EDT) Date: Tue, 25 Apr 2000 16:43:15 -0400 (EDT) From: Greg Pavelcak Subject: Re: Making sh script pause for input In-reply-to: X-Sender: gp@yolen.oit.umass.edu To: Doug Barton Cc: freebsd-questions@FreeBSD.ORG Message-id: MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Content-transfer-encoding: 7BIT X-Authentication-warning: yolen.oit.umass.edu: gp owned process doing -bs Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 25 Apr 2000, Doug Barton wrote: > On Tue, 25 Apr 2000, Alfred Perlstein wrote: > > > * Doug Barton [000425 11:01] wrote: > > > Greg Pavelcak wrote: > > > > > > > > This is driving me nuts. I want a script that prompts with a > > > > student's name and then waits for input regarding that student > > > > then moves on. I've tried using xargs and a script like this: > > > > > > The bad news, you can't do that with sh because once you tell it to > > > take its input from a file that's where it's going to take all of its > > > input from. The good news, this is a really easy perl script, and this > > > kind of processing is one of the things perl is really good for. > > > > Actually... :) > > > > http://www.complete.org/mailinglists/archives/aclug-l-199811/msg00018.html > > > > explains some really nifty things you can do with sh and filehandles. > > None of which apply to the original poster's exmple. He wants to > read from the real stdin while inside a loop which is already reading its > stdin from a file. If you can do what the author asked for in sh, I'd love > to see it. > Just for the record, my original script, #!/bin/sh while read LOGNUM CLASS LNAME FNAME GPA MAJOR ; do grep -iqe "$FNAME \$ $LNAME" appstatus if [ $? -eq 1 ]; then echo $FNAME $LNAME ; echo -n "Status? " ; read STATUS echo "$LOGNUM \$ $CLASS \$ $FNAME \$ $LNAME \$ $GPA \$ $MAJOR \$ $STATUS" >> appstatus ; fi done < contractsS00 was a failure while #!/bin/sh while read LOGNUM CLASS LNAME FNAME GPA MAJOR ; do grep -iqe "$FNAME \$ $LNAME" appstatus if [ $? -eq 1 ]; then echo $FNAME $LNAME ; echo -n "Status? " ; read STATUS < /dev/tty ^^^^^^^^^^ echo "$LOGNUM \$ $CLASS \$ $FNAME \$ $LNAME \$ $GPA \$ $MAJOR \$ $STATUS" >> appstatus ; fi done < contractsS00 was a complete success. I would be glad to credit the kind person who sent this to me, but perhaps he prefers to remain an anonymous sh whiz. Greg To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message