Subject: Re: "yes" curiousity
To: None <port-alpha@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: port-alpha
Date: 06/23/1999 00:55:47
> [...], I went ahead and typed "yes".

> That brings me full circle to my original thought...that seems
> awfully stupid.

It is, as you discovered.  About as useful as typing "cat".

Okay, but seriously... :-)

I've yet to see anyone provide a non-contrived use of "yes".

So, let me do so.  This is a real script, in real use, created to fill
a real need.  The idea is to try to catch media errors on new tapes by
writing them to EOT with junk.  As the tapes are about 4 gig long, it's
no practical to just have a single file which gets dumped to the tape.

Here's the script.  All you need to know about catblock is that it
copies its input to its output in a certain way, and does something
useful when sent SIGUSR1.

#! /bin/sh
PATH=/home/shamash/mouse/sun4/hacks:$PATH
export PATH
cd /home/shamash/mouse/sun4/tmp
junkfile=junk.10M
case $# in
	1)	;;
	*)	echo Usage: $0 config-name 1>&2
		exit 1
		;;
esac
config="$1"
( exec 3>&1
  yes cat\ $junkfile |
	sh -e |
	sh -c 'echo $$ 1>&3; exec catblock -c 32768' \
	> /local/backup/dev/$config/dev 2> junk-log.$config
) | ( read pid; sleep 10; while kill -USR1 $pid; do sleep 300; done )

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B