#!/bin/ksh IDENT=${0##*/} # USAGE="$IDENT" # #Description: This program is used to generate a file of sample records # for CMB to review before running findmatch.ksh #Created: Nella Lall, Sept 2004 #Modified: # # #set -xv # LOG_DIR="" LOG="$LOG_DIR/$IDENT.log" #exec 1>>$LOG 2>&1 if [[ $# -ne 1 || ! -s $1 ]] then echo "ERROR" echo "$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 today=`date +"%Y%m"` i=0 temp=/tmp/sampless$$ workdir=/s/sirsi/Unicorn/Work/NDL/Serialsolutions DEBUG=NO cat $INPUT |\ flatskip -a"SERIAL" -im -of >/dev/null 2>${temp}a total=`grep " ..1411.$" ${temp}a | sed -e 's/^ *//g' -e 's/ .*$//g'` inc_num=`expr $total / 10` #print "This is inc_num $inc_num" inc_numA=$inc_num #Get the first record out: cat $INPUT |\ flatskip -a"SERIAL" -d"N" -im -of -w1 > ${temp}b 2>/dev/null #get the next 9 "random" records out: while [ $i -lt 9 ] do cat $INPUT |\ flatskip -dN -w1 -a"SERIAL" -s"$inc_num" -im -of >> ${temp}b 2>/dev/null inc_num=`expr $inc_num + $inc_numA` #print "This is new inc_num $inc_num" i=`expr $i + 1` #print "This is the incremented i: $i" done if [[ -s ${temp}b ]] then mail -s"Samples for $today SSfile" ndlall@ucalgary.ca < ${temp}b cat ${temp}b > ${workdir}/$today.sample fi #Cleanup if [[ $DEBUG = "NO" ]] then rm -f ${temp}* else print "DEBUG is ON so remember to check and cleanup $temp related files!" print "The end time for this process is `date`" fi exit 0