uusched.sh: a shell script to replace broken uuscheds

Gordon Moffett gam at netcom.uucp
Thu May 3 18:15:12 AEST 1990


This article introduces two tools, one dependent on the other.
The first is 'shuffle' a randomizer of lines of text; and
the other is 'uusched.sh', a shell script version of /usr/lib/uucp/uusched
which uses 'shuffle' to provide it's list of site names to call in
random order.  Since many Xenix systems have uuscheds that don't work
(core dump, etc) like ours, I wanted to get uusched.sh to that audience
as well.
Choose your followup's "Newsgroups:" and "Subject:" appropriately.

The first file in the shar below is 'shuffle', a simple shell script
that is the opposite of sort.  It takes a list of files or standard
input, and prints them out in random order to standard output.
This can be implimented in a number of ways, but this is one of
the most portable versions (thanks to Mickey @ Altos for this one).

This has a few entertaining applications:

shuffle < /etc/passwd | sed 1q	# pick a user at random

shuffle < fortunes | sed 1q	# print a one-liner fortune

It also allows for the shell script equivalent of uusched, 'uusched.sh'
the second file in the shar.  We use here on this Xenix 2.3.2 system
because their uusched is broken.

I'd like to see other ways of doing what 'shuffle' does, as long as it
allows for completely random results, like the last line of input
being the first line of output.

#!/bin/sh
# xshar:	Shell Archiver  (v1.22)
#
#	Run the following text with /bin/sh to create:
#	  shuffle
#	  uusched.sh
#
sed 's/^X//' << 'SHAR_EOF' > shuffle &&
Xawk "BEGIN { srand($$) } { print int(rand()*1000000), \$0 }" $* |
Xsort -n |
Xsed 's/^[0-9]* //'
SHAR_EOF
chmod 0775 shuffle || echo "restore of shuffle fails"
sed 's/^X//' << 'SHAR_EOF' > uusched.sh &&
X: /bin/sh
XPATH=$PATH:/usr/local/bin; export PATH	# to find shuffle
Xfile=/tmp/uu$$
Xtrap "rm -f $file" 0 1 15
X
Xfor site in `uuname | shuffle`
Xdo
X	uustat -s$site > $file
X	if [ -s $file ]
X	then
X		/usr/lib/uucp/uucico -r1 -s$site
X	fi
Xdone
SHAR_EOF
chmod 0775 uusched.sh || echo "restore of uusched.sh fails"
exit 0



More information about the Alt.sources mailing list