#! /usr/bin/ksh if [[ "$1" = "" || "$2" = "" || "$3" = "" ]]; then echo Usage: multilnk input_file link_file output_file echo echo This command file does many-to-many links echo with Suprtool Self-Describing files echo This generic link is done by the primary sort key. echo The output_file must not exist. echo echo Performance tip: echo The file with the smallest number of records should be used as echo the input_file. echo return 1 fi # # Check existence of input files # if [[ ! -s $1 ]]; then echo Sorry I can not find $1. return 1 fi if [[ ! -s $2 ]]; then echo Sorry I can not find $2. return 1 fi if [[ -s $3 ]]; then echo Sorry $3 already exists. Please delete it or choose another name. return 1 fi # # Make sure that files are self-describing # if [[ ! -s $1.sd ]]; then echo Sorry $1 is not a SelfDescribing file. return 1 fi if [[ ! -s $2.sd ]]; then echo Sorry $2 is not a SelfDescribing file. return 1 fi # # The number of records in the input file determines # the number of times we loop # unique_eof=`wc -l $1 | cut -f1 -d " "` echo I will have to do $unique_eof passes to multi-link the files. # # Housekeeping # rm multilog > /dev/null rm multilinklog > /dev/null rm mtomone > /dev/null touch mtomout # # Perform an initialization pass # suprtool << !EOD >> multilog input $1 output mtomone,link,temp exit !EOD # # Set variables with initial values # rec_end=`wc -l $1 | cut -f1 -d " "` rec_nbr=0 append_flag="" # # The second part of the use file is static; # create it only once. # # Here are the Suprlink commands # echo input $2 >suprlink1 echo link mtomone >>suprlink1 echo output mtomout >>suprlink1 echo exit >>suprlink1 # # Here are the Suprtool commands # echo set interactive off > supruse2 echo output mtomone,link,erase >>supruse2 echo xeq >>supruse2 echo !rm mtomout >>supruse2 echo suprlink \< suprlink1 \>\> multilinklog >>supruse2 echo input mtomout >>supruse2 echo output $3,link > supruse3 echo exit >>supruse4 # # This the script mainline. # while [[ $rec_nbr -lt $rec_end ]]; do echo "input $1 ($rec_nbr/$rec_nbr)" > supruse1 suprtool "-c use supruse1;use supruse2;use supruse3;use supruse4" >> multilog if [[ $rec_nbr -eq 0 ]]; then echo output $3,append > supruse3 fi rec_nbr=$(( $rec_nbr+1 )) percent_done="$(( ($rec_nbr * 100) / $unique_eof ))" echo $percent_done% complete. done multi_eof=`wc -l $3 | cut -f1 -d " "` echo The output file, $3, contains $multi_eof entries. echo Check multilog for possible errors.