#!/bin/ksh #This script takes the input name of a file of FLAT ascii records #and loads them into the catalogue see parameters outlined below. # #Sends the newly created ckeys through editcatalog and them through touchkeys #-ptextedit and -pbrowsedit in order for the records to be indexed via #the next adutext report. #N. Lall, July 2000 #N. Lall, modified May 2002 for Serial Solutions #N. Lall, modified March 2003 to run via crontab #N. Lall, modified Dec 2003 to automate steps of getting ALLckeys.sort file # and finding standard named files etc. IDENT=${0##*/} USAGE="$IDENT" #if [[ $# -ne 2 || $2 != 20010101 || ! -s $1 ]] if [[ $# -ne 0 ]] 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 ###### DATE="20010101" temp=`getpathname rpttemp`/loadserials$$ today=`date +"%Y%m%d"` DEBUG=YES workdir=/s/sirsi/Unicorn/Work/NDL/Serialsolutions #Find the date of the input file from the stamp file in $workdir if [[ -s ${workdir}/stamp ]] then cat ${workdir}/stamp |\ while read PT1 do shorttoday=$PT1 done else print "There is no stamp file in ${workdir} so no flat records to load." > ${temp}nogo print "Did findmatch program run first? Investigate" >> ${temp}nogo mail -s"Load SS problems" -c"ndlall@ucalgary.ca" dkbrown@ucalgary.ca < ${temp}nogo exit 0 fi INPUT=${workdir}/$shorttoday.flat INPUTfile=$shorttoday.flat #Load with default of SERIAL record type if none specified in leader of incoming record #-e sends error records into the file named #-bc is selected for match point so that NO matches are found even though # records to be updated exits and matching 001's exist but want to load new # records in and delete the old ones the next day so user is never without # the records. #hs949 tells it to create a copy from the 949 specifications #n"LC,949,a" says create a call number LC class scheme from the 949 subfield a #mc new record creation only, if flex matches, send to error file #found the following too dangerous and had too much trouble with LOCAL tags #anyway, because they are not overlaid. So have to find all the matches first, #remove them out of the system and then import the new file into the system. #mb tells it to overlay a record, if the flex matches, otherwise no match means a new record is created #j says to delete from the incoming bib record after it is loaded using the /Unicorn/Custom/ # junktag file of tags #r tells it to SORT the record for AU/TI/SUB based on the first au/ti/sub tag the system finds # and to record the entries in the record to match the format policy #Accepted defaults of catalog load: #-p default login name of BATCH #-q date catalogued as NEVER until later step when $DATE is used. cat $INPUT |\ catalogload -aSERIAL -bc -if -e"$INPUT.err" -fg -hs"949" -n"LC,949,a" -mc -j -4"junktag.sersolutions" -r 1>$INPUT.ckeys.$today 2>${temp}log #Pop the number of ckeys created into a file so that the remove program #can access this number for it's stats creation report cat $INPUT.ckeys.$today | wc -l | sed -e 's/^ *//g' > ${workdir}/ssloaded #This step puts the information into the history logs that admin edited the record and changes #the date catalogued to that specified by the person running the program cat $INPUT.ckeys.$today |\ editcatalog -q"$DATE" -u4 -8"ADMIN|VT220" 2>>${temp}log #Put the ckeys into /load4/sirsi/Unicorn/Database/Edit so they get indexed in the next run #of adutext cat $INPUT.ckeys.$today |\ touchkeys -ptextedit 2>>${temp}log #Put the ckeys into /load4/sirsi/Unicorn/Database/Browse so they get indexed in the next run #of adutext cat $INPUT.ckeys.$today |\ touchkeys -pbrowsedit 2>>${temp}log cat ${temp}log | translate > ${workdir}/$INPUTfile.log.$today print "Your log for this load of records is found at: $INPUT.log.$today" > ${temp}note print "Your list of CKEYS can be found at: $INPUT.ckeys.$today" >> ${temp}note #Remove the stamp file so we know the load is done and #the file of flat records are never reloaded in error. #Although again, because load is done with create only, #attempted reloads of the same flat file would fail! rm -f ${workdir}/stamp #Create a file of ALL SS ckeys in our Database #Make a backup of the previous ALLckeys.sort file cp -p ${workdir}/ALLckeys.sort ${workdir}/ALLckeys.sort.bak if [[ -s ${workdir}/matchedckeys.sort ]] then comm -23 ${workdir}/ALLckeys.sort ${workdir}/matchedckeys.sort > ${workdir}/leftckeys cat ${workdir}/leftckeys $INPUT.ckeys.$today | sort > ${workdir}/ALLckeys.sort else cat ${workdir}/ALLckeys.sort.bak $INPUT.ckeys.$today | sort > ${workdir}/ALLckeys.sort fi if [[ -s $INPUT.err ]] then #Don't have to move it, it is in this directory already #mv $INPUTfile.err /s/sirsi/Unicorn/Work/NDL/Serialsolutions/$INPUTfile.err print "ANY records which errored out are in: $INPUT.err" >> ${temp}note else rm -f $INPUT.err print "NO records errored out!" >> ${temp}note fi sirsiecho "***********************LOG***************************" >> ${temp}note cat ${workdir}/$INPUTfile.log.$today >> ${temp}note numloaded=`cat $INPUT.ckeys.$today | wc -l | sed -e 's/^ *//g'` print "Load program loaded $numloaded records!" > ${temp}shortnote #REPORT out of all the SS stats for the serialsolutions webpage if no removals #https://www.ucalgary.ca/library/ITS/sirsi/serialsolutions.html if [[ ! -s ${workdir}/matchedckeys.sort ]] then print "" >> ${temp}note print "***UPDATE the serialsolutions.html webpage with stats:" >> ${temp}note cat ${workdir}/sstotalrecords |\ while read PT1 do total=$PT1 done print "Total number of MARC records in SS input file: $total" >> ${temp}note cat ${workdir}/ssloaded |\ while read PT1 do loaded=$PT1 done print "Total number loaded: $loaded" >> ${temp}note print "Total number deleted: 0" >> ${temp}note totaluc=`cat ${workdir}/ALLckeys.sort | wc -l | sed -e 's/^ *//g'` print "Total in our database: $totaluc" >> ${temp}note print "" >> ${temp}note #Backup files with stats in them so not reused in error next month mv ${workdir}/sstotalrecords ${workdir}/sstotalrecords.bak mv ${workdir}/ssloaded ${workdir}/ssloaded.bak fi mail -s"Load of Serials Solutions DONE" -c"ndlall@ucalgary.ca" dkbrown@ucalgary.ca < ${temp}note # mail -s"Load of SS DONE" 2503547260@pcs.rogers.com < ${temp}shortnote mail -s"Load of SS DONE" -c"ndlall@ucalgary.ca" dkbrown@ucalgary.ca < ${temp}shortnote if [[ $DEBUG = "NO" ]] then rm -f ${temp}* fi exit 0