#!/bin/sh
################################################################
#
# Shell script: patron-extract
#
# 1999, Michael Doran, doran@uta.edu
# University of Texas at Arlington Libraries
#
# 1) Extracts SSN, status, & name for faculty from the
# patron upload file obtained from AIS.
#
# 2) Extracts Social Security Numbers from the
# patron upload file obtained from AIS.
#
# 3) Moves LBJ00024.D02 file to Rocky
#
# see: Patron Record Standard Information File (SIF)
# in the Voyager Technical Manual
# *** SIF updated for 99.1 ***
#
# see also: /usr/local/scripts/patron-update
#
# Runs from root crontab
#
################################################################
# Variables
script_name=$0
day=`date +%a`
ais_path=/export/home/aisftp
ptn_file=${ais_path}/LBJ00024.D01
tmp_file=${ais_path}/extract.tmp
fac_file=${ais_path}/faculty.tmp
dum_file=${ais_path}/uncover.txt
cat_file=${ais_path}/faculty.txt
ssn_file=${ais_path}/ssns.uta
d02_file=${ais_path}/LBJ00024.D02 # File that Marie needs
sess_file=${ais_path}/ptrn-x.log # Session file
uncover=rocky:/home/uncover
parking=rocky:/home/tmp
# Function to add comments to session file
add ()
{
/usr/bin/echo "$1" >> ${sess_file} 2>&1
}
# Function to mail session file to operator
swoosh ()
{
/usr/bin/mailx -s "$1" operator < ${sess_file}
}
# Clear out session file
/usr/bin/echo "Script: ${script_name}\n`date`\n" > ${sess_file}
# Check for available AIS patron file
if [ -f ${ptn_file} ]
then
add " Begin extracting info from ${ptn_file}"
else
add " ERROR: No available patron input file."
swoosh "NO-GO: ${script_name}"
exit 1
fi
ExtractFac ()
{
# For faculty records, strip out the SSN,
# status, last name, and first name
/usr/bin/awk 'substr($0, 46, 3) == "fac" \
{ print substr($0, 269, 9), \
substr($0, 46, 3), \
substr($0, 311, 30), \
"," \
substr($0, 341, 20) }' ${ptn_file} > ${tmp_file}
# Remove excess white space from patron names
/usr/bin/sed -e 's/ *,/,/g' \
-e 's/ *//g' ${tmp_file} > ${fac_file}
# Concatenate faculty list with list of uncover dummie patrons
/usr/bin/cat ${fac_file} ${dum_file} > ${cat_file}
add "${fac_file} concatenated with ${dum_file} to make ${cat_file}"
# Copy faculty listings file over to Uncover's home
# directory on Rocky
/usr/bin/rcp ${cat_file} ${uncover}
add "${cat_file} copied to ${uncover}"
# Remove temporary output file
/usr/bin/rm ${tmp_file}
return 0
}
ExtractSSNs ()
{
# Extract SSN's out of most recent patron SIF file
/usr/bin/awk '{ print substr($0, 269, 9) }' ${ptn_file} > ${ssn_file}
# Copy file of SSN's over to Rocky so that FTP program
# has access to it (rocky:/usr/local/scripts/ssn-xfer.pl)
/usr/bin/rcp ${ssn_file} ${parking}
add "${ssn_file} copied to ${parking}"
return 0
}
XferLBJD02()
{
# Copy additional, unprocessed file over to Rocky
# This file is needed by Marie Irwin and will be FTP'd to www2.uta.edu
if [ -f ${d02_file} ]
then
/usr/bin/rcp ${d02_file} ${parking}
add "${d02_file} copied to ${parking}"
else
add " ERROR: No available LBJ00024.D02 file."
fi
return 0
}
ExtractFac >> ${sess_file} 2>&1
ExtractSSNs >> ${sess_file} 2>&1
XferLBJD02 >> ${sess_file} 2>&1
add "\nSession file: ${sess_file}\n`date`"
swoosh "Patron extract done"
exit 0
|