From owner-freebsd-questions Tue Apr 25 9:56:19 2000 Delivered-To: freebsd-questions@freebsd.org Received: from dt051n0b.san.rr.com (dt051n0b.san.rr.com [204.210.32.11]) by hub.freebsd.org (Postfix) with ESMTP id 8927137BEDB for ; Tue, 25 Apr 2000 09:56:15 -0700 (PDT) (envelope-from Doug@gorean.org) Received: from gorean.org (doug@master [10.0.0.2]) by dt051n0b.san.rr.com (8.9.3/8.9.3) with ESMTP id JAA37857; Tue, 25 Apr 2000 09:55:59 -0700 (PDT) (envelope-from Doug@gorean.org) Message-ID: <3905CE1F.CAD4A911@gorean.org> Date: Tue, 25 Apr 2000 09:55:59 -0700 From: Doug Barton Organization: Triborough Bridge & Tunnel Authority X-Mailer: Mozilla 4.72 [en] (X11; U; FreeBSD 5.0-CURRENT-0422 i386) X-Accept-Language: en MIME-Version: 1.0 To: Greg Pavelcak Cc: freebsd-questions@freebsd.org Subject: Re: Making sh script pause for input References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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. Good luck, Doug -- Excess on occasion is exhilarating. It prevents moderation from acquiring the deadening effect of a habit. -- W. Somerset Maugham Beware line wrapping #!/usr/bin/perl -w open(CONTRACTS, "contractsS00") or die "Can't open contractsS00 for read: $!"; open(NEW, ">newfile") or die "Can't open newfile for write: $!"; while () { # Strip the newline off the end of the line chomp; # Split the input line on whitespace ($lognum, $class, $lname, $fname, $gpa, $major) = (split / /); print "\n$fname $lname\n"; print "Status? "; chomp($status = ); print NEW "$lognum $class $lname $fname $gpa $major $status\n"; } close CONTRACTS; close NEW; print "\nDone\n\n"; exit 0; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message