Michael Doran Home Page
Contact | Site Map | Search  
  Home > Archives > Using Scripts > Reading & Writing > Example #1: patron-update 5
This page is deprecated: please read archives disclaimer.

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.
#
###################################################

# Variables
 sess_file=/tmp/ptrnupdt.$$       #  Session file
 mail_rcp=doran@uta.edu           #  Session file recipient
 script_name=$0                   #  Script name
 day=`date +%a`                   #  Abbrev weekday name
 vpath=/m1/voyager/xxxdb          #  Voyager file path

# Files
 update_prog=${vpath}/sbin/Pptrnupdt
 audit_file=${vpath}/rpt/patron.aud.${day}
 error_file=${vpath}/rpt/patron.err.${day}
 update_file=/export/home/aisftp/LBJ00024.D01
 update_save=/export/home/aisftp/ptrn-updt.${day}

# Create session file
/usr/bin/echo "Script ${script_name}\n`date`" >> ${sess_file}

# Clear out this day's audit and error files
# otherwise, Pptrnupdt will append to old
/usr/bin/echo "" > ${audit_file}
/usr/bin/echo "" > ${error_file}

# Do update
if [ -s ${update_file} ]
then
    ${update_prog} \
    -p ${update_file} \
    -m 2000 \
    -e ${error_file} \
    -a ${audit_file} \
    -o I >> ${sess_file} 2>&1
    /usr/bin/mv ${update_file} ${update_save} >> ${sess_file} 2>&1
else
    /usr/bin/echo "Patron update not run: No file from AIS" >> ${sess_file}
    /usr/bin/mailx -s "ABORT: Patron Update" ${mail_rcp} < ${sess_file}
    exit 1
fi


# Send email to Systems person and Cen Circ person
/usr/bin/echo "${script_name} complete\n`date`" >> ${sess_file}
/usr/bin/mailx -s "Patron Update" ${mail_rcp} < ${sess_file}

# and exit script
exit 0