#!/bin/ksh ######################################################################## ### some program setup # filepath filepath=/home/library/marcdata # get name of file to be processed, from the command line if [ -z ${1} ]; then print " " print "Usage: prodimport.script filename.ext" print " where filename.ext is the marc file to" print " preprocessed and imported" print "You must be VOYAGER to run this process!" print " " exit fi waitabit() # this routine waits for a minute so that prebulk will run without # overwriting its log files. # it also provides visual countdown information ( delay=60 print -n "waiting $delay" while [ $delay -gt 0 ] do sleep 1 delay=$(( ${delay} - 1)) printf "\b\b\b\b\b\b\b\b\b\b\bwaiting $delay " done printf "\b\b\b\b\b\b\b\b\b\b " ) ######################################################################## ### files # prebulk config pblcno=$filepath/prebulk_lc_no.cfg # gpo to lc remap = no pblcyes=$filepath/prebulk_lc_yes.cfg # gpo to lc remap = yes pbwwwyes=$filepath/prebulk_www_yes.cfg # with "049 |a wdoc,www" pbwwwno=$filepath/prebulk_www_no.cfg # without "049 |a wdoc,www" # marcedit config # tells marcedit what to do mewwwyesadd099=$filepath/marcedit_www_yes_add_099.ini mewwwyesminus099=$filepath/marcedit_www_yes_minus_099.ini meyesmap=$filepath/marcedit_yesmap.ini menomap=$filepath/marcedit_nomap.ini meyesnaut=$filepath/marcedit_yesnaut.ini menonaut=$filepath/marcedit_nonaut.ini menowww=$filepath/marcedit_nowww.ini me655=$filepath/marcedit_655.ini # data # files with a .imp extension are ready for bulkimport wmich8yes=$filepath/wmich8.lcyes # these two come from wmich8.pl wmich8no=$filepath/wmich8.lcno # wwwyesb=$filepath/wmich8.yeswww.imp wmich8yesmap=$filepath/wmich8.yesmap wmich8nomap=$filepath/wmich8.nomap wmich8yesnaut=$filepath/wmich8.yesnaut wmich8nonaut=$filepath/wmich8.nonaut wmich8nowww=$filepath/wmich8.nowww wwwnob=$wmich8nowww.imp wmich8ymimp=wmich8yesmap.imp wmich8ynimp=wmich8yesnaut.imp wmich8yesmapimp=$filepath/$wmich8ymimp wmich8yesnautimp=$filepath/$wmich8ynimp fileimp=${1}.finalimp ######################################################################## # all records need to have 655 |2 edited # attempt cleanup in case of previous runs with this filename print " " print "Attempting removal of previous files, if any;" print "will get warning if they're not found." print "This may happen several more times in this script." print " " rm $1.655 marcedit $1 $1.655 $me655 ######################################################################## # do the maplc processing. # does gpo->lc remapping where applicable. # outputs two files: remapped(yes) and unremapped(no). # the remapped data is run through prebulk and is sent on for bulk import. # remap the data where possible $filepath/wmich8.pl $1.655 filepb=$wmich8yes fileb=$filepb.imp rm $fileimp $fileb # run prebulk import /m1/voyager/wmichdb/sbin/Pprebulk \ -i$filepb \ -o$fileb \ -c$pblcyes marccount $fileb cat $fileb >> $fileimp # start building the import file waitabit ######################################################################## # here we select those records that were not remapped, but do have # 049 |a of "wmap,map", run them through prebulk, and send them # on to bulk import. # also email an intermediate file for inspection. rm $wmich8yesmap $wmich8yesmapimp marcedit $wmich8no $wmich8yesmap $meyesmap # run prebulk import /m1/voyager/wmichdb/sbin/Pprebulk \ -i$wmich8yesmap \ -o$wmich8yesmapimp \ -c$pblcno marccount $wmich8yesmapimp cat $wmich8yesmapimp >> $fileimp echo This is from file $1 > /tmp/$wmich8ymimp.read echo >> /tmp/$wmich8ymimp.read marcread $wmich8yesmapimp >> /tmp/$wmich8ymimp.read mailx email.recipient@institution.edu < /tmp/$wmich8ymimp.read waitabit ######################################################################## # here we select those records that were not remapped, but do have # 049 |a of "wmap,naut", run them through prebulk, and send them # on to bulk import rm $wmich8yesnaut $wmich8yesnautimp marcedit $wmich8no $wmich8yesnaut $meyesnaut # run prebulk import /m1/voyager/wmichdb/sbin/Pprebulk \ -i$wmich8yesnaut \ -o$wmich8yesnautimp \ -c$pblcno marccount $wmich8yesnautimp cat $wmich8yesnautimp >> $fileimp waitabit ######################################################################## # here we handle expected non-remapped data. # for certain records, the existing 099 is replaced with our own # version, then this data is run through prebulk and sent on to # bulk import. rm $wmich8no.wwwminus $wmich8no.wwwadd $wwwyesb marcedit $wmich8no $wmich8no.wwwminus $mewwwyesminus099 marcedit $wmich8no.wwwminus $wmich8no.wwwadd $mewwwyesadd099 # run prebulk import /m1/voyager/wmichdb/sbin/Pprebulk \ -i$wmich8no.wwwadd \ -o$wwwyesb \ -c$pbwwwyes marccount $wwwyesb cat $wwwyesb >> $fileimp waitabit ######################################################################## # from the expected non-remapped data, we remove any 049 |a "wmap,map, # "wmap,naut", and "wdoc,www" records, put the remaining data through # prebulk, and send it on to bulk import rm $wmich8nomap $wmich8nonaut $wmich8nowww $wwwnob marcedit $wmich8no $wmich8nomap $menomap marcedit $wmich8nomap $wmich8nonaut $menonaut marcedit $wmich8nonaut $wmich8nowww $menowww # run prebulk import /m1/voyager/wmichdb/sbin/Pprebulk \ -i$wmich8nowww \ -o$wwwnob \ -c$pbwwwno marccount $wwwnob cat $wwwnob >> $fileimp marccount $fileimp ######################################################################## # run bulk import for the previously prepared data /m1/voyager/wmichdb/sbin/Pbulkimport \ -f$fileimp \ -iMARCIVE \ -obulkimport