Michael Doran Home Page
Contact | Site Map | Search  
  Home > Archives > Using Scripts > bursar-xfer
Using Scripts to Automate Voyager Tasks

bursar-xfer

Session File

#!/bin/ksh

######################################################
#
#  Shell script: bursar-xfer
#
#  1999, Michael Doran, doran@uta.edu 
#  University of Texas at Arlington Libraries
#
#  Runs the Voyager bursar program which generates a
#  patron fines and fees file.  That file is copied
#  to the AIS home directory for transfer to the 
#  UTA bursar's office.  (Melissa Ferguson, x2471)
#
#  Saves one week's worth of bursar SIF, log, and
#  error files in the voyager "rpt" directory.
#
#  See: Voyager Technical Manual, p. 43
#
#  Runs via the "voyager" crontab.
#
######################################################

# Variables
 script_name=$0                   #  Script name
 vpath=/m1/voyager/xxxdb          #  Voyager file path
 sess_file=/tmp/bursxfer.$$       #  Session file
 mail_rcp=doran                   #  Session file recipient
 circ_rcp=cencirc                 #  Log file recipient

# Files
 xfr_prog=${vpath}/sbin/Pbursar
 cfg_file=${vpath}/sbin/bursar.cfg
 out_file=${vpath}/rpt/sif.burs.`date +%Y%m%d`.*
 out_save=${vpath}/rpt/bursar.sif.`date +%a`
 log_file=${vpath}/rpt/log.burs.`date +%Y%m%d`.*
 log_save=${vpath}/rpt/bursar.log.`date +%a`
 err_file=${vpath}/rpt/err.burs.`date +%Y%m%d`.*
 err_save=${vpath}/rpt/bursar.err.`date +%a`
 ais_file=/export/home/aisftp/bursar.sif

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

# Create (or clear out) session file
add "Script: ${script_name}\n`date`\n"

# Check to make sure previous SIF file has been ftp'd by AIS
if [ -s ${ais_file} ]
then
    add "Bursar program not run: AIS has not retrieved previous output file."
    /usr/bin/mailx -s "ABORT: Bursar Transfer" ${mail_rcp} < ${sess_file}
    exit 1
fi

# Check for the presence of bursar transfer program and config file
if [ -s ${cfg_file} -a -x ${xfr_prog} ]
then  # if present, run the program
    ${xfr_prog} -c ${cfg_file} >> ${sess_file} 2>&1
    add "\nExit status of Pbursar: $?\n"
    # Keep copy of SIF file in the rpt directory
    /usr/bin/cp ${out_file} ${out_save} >> ${sess_file} 2>&1
    # Transfer SIF file to the AIS home directory
    /usr/bin/mv ${out_file} ${ais_file} >> ${sess_file} 2>&1
else
    add "ERROR: Missing config file and/or tranfer program"
    /usr/bin/mailx -s "ABORT: Bursar Transfer" ${mail_rcp} < ${sess_file}
    exit 1
fi

# Add log file info to session file
/usr/bin/cat ${log_file} >> ${sess_file} 2>&1

# Rename log and error files per one week retention schedule
/usr/bin/mv ${log_file} ${log_save} >> ${sess_file} 2>&1
/usr/bin/mv ${err_file} ${err_save} >> ${sess_file} 2>&1
# Reminder about location of files
add "Log file: ${log_save}"
add "Error file: ${err_save}\n"

# send session file to sysadmin and Central Circulation
add "${script_name} complete\n`date`"
/usr/bin/mailx -s "Bursar Transfer Log File" ${circ_rcp} < ${sess_file}
/usr/bin/mailx -s "Bursar Transfer" ${mail_rcp} < ${sess_file}

# and exit script
exit 0