#!/bin/ksh #This script takes the new Serial Solutions marc file and extracts #the 001 tags and matches them to the 001's within the catalogue database to #determine matches. (for "overlay") and also gets their ckeys # #It outputs matching ckeys found via seltext # # #N. Lall, July 2002 # #Modified: N. Lall, Dec 2003 IDENT=${0##*/} USAGE="$IDENT " #if [[ $# -ne 2 || ! -s $1 || -s $2 ]] if [[ $# -ne 1 || ! -s $1 ]] then echo "ERROR: $USAGE" exit 1 fi ####### System dependent. Change BRSConfig, UPATH and PATH accordingly. export BRSConfig=/s/sirsi/Unicorn/Config/brspath export UPATH=/s/sirsi/Unicorn/Config/upath PATH=$PATH:/s/sirsi/Unicorn/Bincustom:/s/sirsi/Unicorn/Search/Bin/:/s/sirsi/Unicorn/Bin:/usr/local/bin:/usr/bin; export PATH ###### INPUT=$1 INPUTfile=`echo $INPUT | sed -e 's/\/..*\///g'` #OUTPUT=$2 #OUTPUTfile=`echo $OUTPUT | sed -e 's/\/..*\///g'` temp=`getpathname rpttemp`/findmatchss$$ today=`date +"%Y%m"` DEBUG=NO workdir=/s/sirsi/Unicorn/Work/NDL/Serialsolutions OUTPUT=${workdir}/matchedckeys #There should be no $OUTPUT.sort file if the remove program ran last month! if [[ -s $OUTPUT.sort ]] then #report this out and stop the program print "Error, there already is a $OUTPUT.sort file" > ${temp}msg print "Did remove program run last month? Investigate!" >> ${temp}msg mail -s"Problem with findmatch SS program" -c"ndlall@ucalgary.ca" dkbrown@ucalgary.ca < ${temp}msg exit 1 fi cat $INPUT | marcprint -t"001" > ${temp}a 2>/dev/null if [[ ! -s ${temp}a ]] then print "Error, no tag 001s generated, check input file name." > ${temp}msg mail -s"INPUT name wrong for findmatch" -c"ndlall@ucalgary.ca" dkbrown@ucalgary.ca < ${temp}msg exit 1 else cat ${temp}a | sed -e 's/^num=001 //g' > ${temp}b if [[ -s ${temp}b ]] then cat ${temp}b |\ while read PT1 do sirsiecho "$PT1 {001}" | seltext -lBOTH >> ${temp}c 2>${temp}log TEST=`grep -c "Search time limit exceeded" ${temp}log` #print "In the first sirsiecho and TEST being set to: $TEST" until [ $TEST -eq 0 ] do # print "In the second while loop because TEST is not zero it is: $TEST" sirsiecho "$PT1 {001}" | seltext -lBOTH >> ${temp}c 2>${temp}log TEST=`grep -c "Search time limit exceeded" ${temp}log` # print "Test is reset in the loop to: $TEST" done done fi fi if [[ -s ${temp}c ]] then #go back and get the 001s for these ckeys cat ${temp}c | selcatalog -iC -e"001" -oe > $OUTPUT.matched001s 2>/dev/null print "The matched 001s are in $OUTPUT.matched001s." > ${temp}msg #Ensure that all matched ckeys are old loaded Serial Solutions records cat ${temp}c | sort > $OUTPUT.sort comm -23 $OUTPUT.sort ${workdir}/ALLckeys.sort > ${temp}problems print "" >> ${temp}msg print "The matched ckeys are in $OUTPUT.sort." >> ${temp}msg countmatch=`cat $OUTPUT.sort | wc -l | sed -e 's/^ *//g'` print " There were $countmatch records matched in this process." >> ${temp}msg print "" >> ${temp}msg if [[ -s ${temp}problems ]] then print "" >> ${temp}msg print "***NOT all matched ckeys were old Serial Solutions records!" >> ${temp}msg print "Here are the problem ckeys to investigate" >> ${temp}msg cat ${temp}problems >> ${temp}msg else print "All matched ckeys were old Serial Solutions records!" >> ${temp}msg fi #Any records with more than one copy or less than one copy? #These must be reported out and fixed before the remove program will #run. cat $OUTPUT.sort | selitem -iC -oC 2>/dev/null |\ sort > ${temp}ckcopies comm -23 $OUTPUT.sort ${temp}ckcopies > ${temp}nocopy comm -23 ${temp}ckcopies $OUTPUT.sort | sort -u > ${temp}morecopy #Report out any of these oddball copy problems and send to CMB if [[ -s ${temp}nocopy ]] then print "Some matched ckeys have NO copy! Report to Bib.Services" >> ${temp}msg print "The remove old program will not run until these are fixed!" >> ${temp}msg cat ${temp}nocopy >> ${temp}msg fi if [[ -s ${temp}morecopy ]] then print "Some matched ckeys have MORE than one copy! Report to Bib.Services" >> ${temp}msg print "The remove old program will not run until these are fixed!" >> ${temp}msg cat ${temp}morecopy >> ${temp}msg fi #Create the flat file for load into the catalogue without the #delete records (-dN) cat $INPUT |\ flatskip -a"SERIAL" -d"N" -im -of -e"/s/sirsi/Unicorn/Work/NDL/Serialsolutions/flat.err" > ${workdir}/$today.flat 2> ${temp}flatlog #Find out how many records TOTAL are in the SS file for webpage stats #Put into a file for use at end of removeold program so all stats given once grep "marc. ..1305.$" ${temp}flatlog | translate | sed -e 's/[^0-9][^0-9]*//g' > ${workdir}/sstotalrecords #Create a stamp file for this variable to be stored for use in loadNEWcron.ksh sirsiecho $today > ${workdir}/stamp print "" >> ${temp}msg print "Here is the log of converting marc to flat for load" >> ${temp}msg cat ${temp}flatlog | translate >> ${temp}msg print "" >> ${temp}msg if [[ -s /s/sirsi/Unicorn/Work/NDL/Serialsolutions/flat.err ]] then print "" >> ${temp}msg print "Error records are in /s/sirsi/Unicorn/Work/NDL/Serialsolutions/flat.err" >> ${temp}msg print "These were created in the flatskip step of taking the marc records" >> ${temp}msg print "and converting them to flat records." >> ${temp}msg print "The flat records that did not error out are in ${workdir}/$today.flat" >> ${temp}msg else print "The flat records for load are in ${workdir}/$today.flat" >> ${temp}msg print "Setup the crontab for Saturday night to load these with loadNEWcronv2.ksh" >> ${temp}msg print "Setup the crontab for Sat night to remove the matched ckeys with removeoldcronv2.ksh" >> ${temp}msg print "" >> ${temp}msg fi else print "There were no matching 001 tags! Does that seem right?" >> ${temp}msg print "If it seems right, do catalogload with only CREATE mode, no Update." >> ${temp}msg fi mail -s"Findmatch results" -c"ndlall@ucalgary.ca" dkbrown@ucalgary.ca < ${temp}msg if [[ $DEBUG = "NO" ]] then rm -f ${temp}* fi exit 0