Michael Doran Home Page
Contact | Site Map | Search  
  Home > Archives > Using Scripts > lcsh-start
This page is deprecated: please read archives disclaimer.

Using Scripts to Automate Voyager Tasks

lcsh-start

#!/bin/ksh

####################################################
#
#  Shell script: lcsh-start
#
#  2000, Michael Doran, doran@uta.edu
#
#  Quick shell hack to start the LCSH authority
#  records import process.
#
#  Program expects an LCSH filename as an argument
#
####################################################

# Variables
 vygrsbin=/m1/voyager/xxxdb/sbin
 vygrrpts=/m1/voyager/xxxdb/rpt
 filepath=/m1/incoming/LCSH
 import_log=${vygrrpts}/log.imp.`date +%Y%m%d.%H`*
 mail_acs=hopkins@library.uta.edu
 mail_sys=doran


#############################################
# Check for file argument

if [ -z $1 ]  # If there is no file argument,
then          # alert script user
   echo "Usage: $0 file-name (e.g. LCSUB00.31)"
   exit 1
else  # if there is, check for correct syntax
   case $1 in
   LCSUB0[0-3]\.[0-5][0-9])
	echo "File name: $1 is OK"
	;;
   *) 
	echo "Incorrect file name: $1. Syntax: LCSUBYY.WK"
	exit 1
	;;
   esac
fi


#############################################
# Retrieve the LCSH file from Peter Ward

cd ${filepath}

# This works courtesy of /export/home/voyager/.netrc
ftp ftp.database.com <<EOF
        bin
        get $1
        bye
EOF


#############################################
# Run the voyager bulk import batch job
# and Pcatjob number 11 

if [ -s ${filepath}/$1 ]
then
    echo "Starting Pbulkimport"
    ${vygrsbin}/Pbulkimport \
	-f ${filepath}/$1 \
	-i LCSH \
	-n
    if [ $? -eq 0 ]
    then
	/usr/bin/mv ${filepath}/$1 ${filepath}/done
	echo "$1 moved to ${filepath}/done"
	echo "Starting Pcatjob -j11"
	${vygrsbin}/Pcatjob -j11
    else
	echo "Pbulkimport had non-zero exit status."
	echo "Pcatjob -j11 NOT run."
    fi
fi


#################################################
# Send logfile to ACS person and sysadmin

if [ -s ${import_log} ]
then
    tail -15 ${import_log} | mailx \
	-s "$1 log file" -c ${mail_sys} ${mail_acs}
else
    echo "$0 can't find ${import_log}" | mailx \
	-s "Script problem" ${mail_sys}
fi


#################################################
# If these additional files exist and have a size
# greater than zero, send them to ACS person

for file in delete discard replace reject err
do
   add_file=${vygrrpts}/${file}.imp.`date +%Y%m%d.%H`*
   if [ -s ${add_file} ]
   then
	mailx -s "$1 ${file}" ${mail_acs} < ${add_file}
   fi
done


#################################################
# exit gracefully out of script

exit 0