Michael Doran Home Page
Contact | Site Map | Search  
  Home > Archives > Using Scripts > Reading & Writing > Example #1: patron-update 4
Using Scripts to Automate Voyager Tasks

Example #1: patron-update 1 2 3 4 5 6

#!/bin/ksh

###################################################
#
#  Shell script: patron-update
#
#  1999, Michael Doran, doran@uta.edu
#  University of Texas at Arlington Libraries 
#
#  Runs the Voyager Patron Update program (see
#  Voyager Technical Manual, page 65) which
#  takes a patron file generated and FTP'd over
#  by AIS and updates the Voyager patron database. 
#
#  Saves one week's worth of patron SIF, audit,
#  and error files.
#
#  Runs via the "voyager" crontab.
#
###################################################

# Create session file
/usr/bin/echo "Script $0\n`date`" >> /tmp/ptrnupdt.$$

# Clear out this day's audit and error files
# otherwise, Pptrnupdt will append to old
/usr/bin/echo "" > /m1/voyager/xxxdb/rpt/patron.aud.`date +%a`
/usr/bin/echo "" > /m1/voyager/xxxdb/rpt/patron.err.`date +%a`

# Do update
if [ -s /export/home/aisftp/LBJ00024.D01 ]
then
    /m1/voyager/xxxdb/sbin/Pptrnupdt \
    -p /export/home/aisftp/LBJ00024.D01 \
    -m 2000 \
    -e /m1/voyager/xxxdb/rpt/patron.err.`date +%a` \
    -a /m1/voyager/xxxdb/rpt/patron.aud.`date +%a` \
    -o I >> /tmp/ptrnupdt.$$ 2>&1
    /usr/bin/mv /export/home/aisftp/LBJ00024.D01 \
     /export/home/aisftp/ptrn-updt.`date +%a` >> /tmp/ptrnupdt.$$ 2>&1
else
    /usr/bin/echo "Patron update not run: No file from AIS" >> /tmp/ptrnupdt.$$
    /usr/bin/mailx -s "ABORT: Patron Update" doran@uta.edu < /tmp/ptrnupdt.$$
    exit 1
fi

# Send email to Systems person
/usr/bin/echo "$0 complete\n`date`" >> /tmp/ptrnupdt.$$
/usr/bin/mailx -s "Patron Update" doran@uta.edu < /tmp/ptrnupdt.$$

# and exit script
exit 0