Home Contact
Validate the HTML of this page

patron-update-ldump.sh

source code


#!/bin/ksh

###################################################
#
#  Shell script: patron-update-ldump.sh
#
#  1999, 2005, 2006 Michael Doran, doran@uta.edu
#  University of Texas at Arlington Libraries 
#
#  Runs the Voyager Patron Update program which
#  takes a patron file generated from the CEDAR 
#  directory and updates the Voyager patron database. 
#
#  Runs via the "voyager" crontab.
#
###################################################

# Variables
 sess_file=/tmp/ptrnupdt.$$       #  Session file
 mail_rcp=vygradmin@xxx.edu       #  Session file recipient
 circ_rcp=circperson@xxx.edu      #  Audit file recipient
 script_name=$0                   #  Script name
 vpath=/m1/voyager/xxxdb          #  Voyager file path
 cpath=/path-to                   #  CEDAR file path

# Files
 update_file=${cpath}/ldump.sif
   ldump_log=${cpath}/ldump.log
 update_prog=${vpath}/sbin/Pptrnupdt
  audit_file=${cpath}/patron.aud
  error_file=${cpath}/patron.err

# Delete previous session files with this PID 
if [ -s ${sess_file} ]
then
    /usr/bin/rm ${sess_file}
fi

#Function to add comments to session file
add ()
{
    /usr/bin/echo "$1" >> ${sess_file}
}

# Create session file
add "Script ${script_name}\n`date`"

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

# Check for Patron SIF file 
if [ -s ${update_file} ]
then
    /usr/bin/echo "\n$ldump_log file: \n" >> ${sess_file}
    /usr/bin/cat $ldump_log >> ${sess_file}
else
    add "\nPatron update not run: No CEDAR dump file."
    /usr/bin/mailx -s "ABORT: Patron Update" ${mail_rcp} < ${sess_file}
    exit 1
fi

if [ -x ${update_prog} ]
then
    ${update_prog} \
    -p ${update_file} \
    -m 5000 \
    -iI \
    -e ${error_file} \
    -a ${audit_file} \
    -o I >> ${sess_file} 2>&1
    /usr/bin/rm ${update_file} >> ${sess_file} 2>&1
else
    add "Patron update not run: Problem with ${update_prog} or ${update_file}"
    /usr/bin/mailx -s "ABORT: Patron Update" ${mail_rcp} < ${sess_file}
    exit 1
fi


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

# and exit script
exit 0