Cover V05, I10
Article
Listing 1
Listing 10
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6
Listing 7
Listing 8
Listing 9

oct96.tar


Listing 4: pseudo.sh

:
#######################################################
# pseudo.sh - sample script
#######################################################
# pseudo.sh - this script is run prior to fchange.sh so
# that pseudo-files such as the output from ypcat hosts
# may be checked.  This also allows you to check the
# contents of a directory by simply doing an ls and
# saving the output to a file.
#
# Here's how it works.  Do something (ls or run a
# program or whatever) and save the output in a tmpfile.
# Compare that output with the current_file.  If the
# contents of tmpfile differ from current_file, then
# move tmpfile to current_file and let fchange.sh do the
# rest.  If there are no differences, then do nothing;
# and fchange.sh will do nothing too.

test "$debugxv" && set -xv # primitive debugger

# make your changes here.  this is $ctrldir
cwd=/u/stevei/fchange

cd $cwd/pseudo || {
echo "Error:could not cd to: $cwd/pseudo"
exit 1
}
tmpfile=${TMPDIR:=/tmp}/pseu.$$

#------------------------------------------------------
#                  pseudo files
#------------------------------------------------------
# recall that we're now in the pseudo directory

# format:
#   program outputfilename

echo "$cwd/notafile.sh notafile.out
$cwd/diskspace.sh diskspace.out" |
while read prog file
do
eval $prog > $tmpfile
eval diff $tmpfile $file > /dev/null || \
mv $tmpfile $file
done

rm -f $tmpfile
exit 0