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


