Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Apr 2000 14:19:15 -0700
From:      Alfred Perlstein <bright@wintelcom.net>
To:        Doug Barton <Doug@gorean.org>
Cc:        Greg Pavelcak <gpav@som.umass.edu>, freebsd-questions@FreeBSD.ORG
Subject:   Re: Making sh script pause for input
Message-ID:  <20000425141915.G9754@fw.wintelcom.net>
In-Reply-To: <Pine.BSF.4.21.0004251258300.38506-100000@dt051n0b.san.rr.com>; from Doug@gorean.org on Tue, Apr 25, 2000 at 01:01:49PM -0700
References:  <20000425110642.D9754@fw.wintelcom.net> <Pine.BSF.4.21.0004251258300.38506-100000@dt051n0b.san.rr.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* Doug Barton <Doug@gorean.org> [000425 13:31] wrote:
> On Tue, 25 Apr 2000, Alfred Perlstein wrote:
> 
> > * Doug Barton <Doug@gorean.org> [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. 
> 
> 	I'm as big of a bourne shell scripting advocate as anyone, but
> there are some things that it doesn't do well, and this is one of them. 
> 


#!/bin/sh
#(ph33r) 
exec 3<contractsS00

while read LOGNUM CLASS LNAME FNAME GPA MAJOR 0<&3 ;
do 
	echo $FNAME $LNAME ;
	echo -n "Status? " ;
	read STATUS ;
	echo "$LOGNUM $CLASS $LNAME $FNAME $GPA $MAJOR $STATUS" >> newfile ;
done 

-- 
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000425141915.G9754>