Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!pmafire!uudell!bigtex!texsun!male!newstop!exodus!ichthous.Eng.Sun.COM!mcgrew From: mcgrew@ichthous.Eng.Sun.COM (Darin McGrew) Newsgroups: comp.unix.shell Subject: Re: Prompting for yes/no in csh Message-ID: <5459@exodus.Eng.Sun.COM> Date: 8 Jan 91 17:24:18 GMT References: <3821@ns-mx.uiowa.edu> Sender: news@exodus.Eng.Sun.COM Distribution: usa Organization: Sun Microsystems, Mt. View, Ca. Lines: 25 dkeber@umaxc.weeg.uiowa.edu (Dave Keber) writes: >What is the easiest way to prompt for a yes/no (or any string/number, etc.) >from a csh shell script? The standard way is to use the pseudo-variable "$<" as follows-- #!/bin/csh echo -n "Really [yn]? " set answer = "$<" echo "You answered '$answer'" >I thought of writing a short C program that asks for input then writing the >answer to standard output, and then calling that program in my shell script, >but that seems a rather convoluted way of going about it...or is it? Well, yes, it's convoluted. But you don't have to write a new tool to do it this way-- #!/bin/csh echo -n "Really [yn]? " set answer = "`head -1`" echo "You answered '$answer'" Darin McGrew mcgrew@Eng.Sun.COM Affiliation stated for identification purposes only.