#!/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 , Aug 2010 for overlay of matched records IDENT=${0##*/} USAGE="$IDENT " #if [[ $# -ne 2 || ! -s $1 || -s $2 ]] if [[ $# -ne 1 || ! -s $1 ]] then echo "ERROR: $USAGE" exit 1 fi #Use Damon's better way of calling all the settings from Config/environ: . /sirsi/s/sirsi/Unicorn/Config/environ for i in `cut -f1 -d= /sirsi/s/sirsi/Unicorn/Config/environ` do export $i done ###### 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=YES workdir=/sirsi/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 mailx -s"Problem with findmatchv3 SS program" ndlall@ucalgary.ca < ${temp}msg mailx -s"Problem with findmatchv3 SS program" dkbrown@ucalgary.ca < ${temp}msg exit 1 fi #Check that LOCAL tags in SERIAL format have not changed since last time: cat /s/sirsi/Unicorn/Custom/Format/ENTRY.7 |\ selascii -iR -oF1 -r 25 "L" 2>/dev/null |\ sort > ${temp}testlocal sdiff -s ${temp}testlocal ${workdir}/SERIALlocaltags.bak > ${temp}testlocal.out if [[ -s ${temp}testlocal.out ]] then #report this out and stop the program print "LOCAL tags in SERIAL format have changed since last run." > ${temp}msg print "You will need to change the remlocal.dat file to reflect the changes." >> ${temp}msg print "Here is the list of current LOCAL tags in SERIAL format:" >> ${temp}msg cat ${temp}testlocal >> ${temp}msg mailx -s"Problem with findmatchv3 SS program" ndlall@ucalgary.ca < ${temp}msg mailx -s"Problem with findmatchv3 SS program" 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 mailx -s"INPUT name wrong for findmatch" ndlall@ucalgary.ca < ${temp}msg mailx -s"INPUT name wrong for findmatch" 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. Feb 2009--group records now so report out but remove program #WILL remove them. 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 run AND remove these now that we have GROUP records!" >> ${temp}msg # cat ${temp}morecopy >> ${temp}msg # fi #Do the steps of removing LOCAL tags and changing the call number to AUTO XX call num # for all the MATCHED cases and remove all copies before overlaying them cat $OUTPUT.sort |\ editmarc -f"${workdir}/remlocal.dat" -u > ${temp}remlocal 2> ${temp}remlocal.log cat $OUTPUT.sort | selitem -iC -oBC 2>/dev/null |\ sort -t"|" -u +1 -2 | ${workdir}/makeapifile.pl |\ apiserver -e"${workdir}/api.err" -h > ${temp}apiout 2> ${temp}apiout.err if [[ -s ${workdir}api.err ]] then print "There were some api.errs to investigate!" >> ${temp}msg fi cat $OUTPUT.sort | selitem -iC -oI 2>/dev/null |\ remitem -l"ADMIN|VT100" > ${temp}remitem 2> ${temp}remitem.err #now to handle the full delete cases...may try catalogload -Dd first #otherwise get the 001s of the delete cases, match them and delete with delitem # cat $INPUT |\ # flatskip -a"SERIAL" -d"Y" -im -om 2>/dev/null |\ # marcprint -t"001" > ${temp}delete001s #Create the file for load into the catalogue with the #delete records (use to use to ignore the delete records, now need them -dN) cat $INPUT |\ flatskip -a"SERIAL" -im -om -e"/sirsi/s/sirsi/Unicorn/Work/NDL/Serialsolutions/flat.err" > ${workdir}/$today.mrc 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 through flatskip 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 records to load." >> ${temp}msg print "The flat records that did not error out are in ${workdir}/$today.flat" >> ${temp}msg else print "The marc records for load are in ${workdir}/$today.flat" >> ${temp}msg print "Setup the crontab to load these with loadNEWcronv3.ksh" >> ${temp}msg print "" >> ${temp}msg fi else #Create the flat file for load into the catalogue with the #delete records (use to use to ignore the delete records, now need them -dN) cat $INPUT |\ flatskip -a"SERIAL" -im -om -e"/sirsi/s/sirsi/Unicorn/Work/NDL/Serialsolutions/flat.err" > ${workdir}/$today.mrc 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 through flatskip 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 records to load." >> ${temp}msg print "The flat records that did not error out are in ${workdir}/$today.flat" >> ${temp}msg else print "The marc records for load are in ${workdir}/$today.flat" >> ${temp}msg print "Setup the crontab to load these with loadNEWcronv3.ksh" >> ${temp}msg print "" >> ${temp}msg fi 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 mailx -s"Findmatch results" ndlall@ucalgary.ca < ${temp}msg #mailx -s"Findmatch results" dkbrown@ucalgary.ca < ${temp}msg cat ${temp}msg > ${workdir}/findmatchrpt.$today if [[ $DEBUG = "NO" ]] then rm -f ${temp}* fi exit 0