
# @(#) recovery  ver. 1.2 last update 86/12/21 10:26:55
# 'recovery shell script
if [ "$1" -a "$2" ]
  then 
   if [ -w $1 ] 
     then
      echo Attempt to recover $1 in place:
      echo Press RETURN when ready . . .
      read yesno
      recover1 $1 $2
      if [ $? -ne 1 ] 
        then
         echo Index file $1 recovered in place.  
         echo Records with invalid duplicate keys can be found in $2.
        else 
         echo Attempt to extract data records from $1 
         echo "(file structure will be retrieved from the original index file):"
         echo Press RETURN when ready . . .
         read yesno
         runcobol recover2 -k -a "$1,$3,NOSUB"
         if [ $? -ne 1 ] 
           then
            echo The data recovery file specified for RECOVER2 contains the data records
            echo  from index file $1.  
            echo  See Utilities Supplement to rebuild index file.
           else 
            echo Attempt to extract data records from $1 
            echo "(file structure must be supplied by user):"
            echo Press RETURN when ready . . .
            read yesno
            runcobol recover2 -k -a "$1,$3,SUB"
            if [ $? -ne 1 ] 
              then
               echo The data recovery file specified for RECOVER2 contains the data records
               echo  from index file $1.  
               echo  See Utilities Supplement to rebuild index file.
              else 
               echo Recovery failed.  A portion of the data records from index file $1 may
               echo  exist in the data recovery file specified for RECOVER2.
               echo  See Utilities Supplement.
            fi
         fi
      fi
     else 
      echo File $1 does not exist - execution terminated
   fi
  else 
   echo Usage:     recovery index-file-name drop-file-name [data-recovery-file-name]
fi
