home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / EDITOR / NVI179B / NVI179B.ZIP / os2 / recover.cmd < prev    next >
OS/2 REXX Batch file  |  1997-06-29  |  1KB  |  51 lines

  1. extproc c:/gnu/bin/sh.exe
  2. #!/bin/sh -
  3. #
  4. #    @(#)recover.in    8.8 (Berkeley) 10/10/96
  5. #
  6. # Script to recover nvi edit sessions.
  7.  
  8. RECDIR="C:/tmp/recover.vi"
  9. SENDMAIL="C:/TCPIP/BIN/sendmail"
  10.  
  11. echo 'Recovering nvi editor sessions.'
  12.  
  13. # Check editor backup files.
  14. vibackup=`echo $RECDIR/vi*`
  15. if [ "$vibackup" != "$RECDIR/vi*" ]; then
  16.     for i in $vibackup; do
  17.         # Only test files that are readable.
  18.         if test ! -r $i; then
  19.             continue
  20.         fi
  21.  
  22.         # Unmodified nvi editor backup files either have the
  23.         # execute bit set or are zero length.  Delete them.
  24.         if test -x $i -o ! -s $i; then
  25.             rm $i
  26.         fi
  27.     done
  28. fi
  29.  
  30. # It is possible to get incomplete recovery files, if the editor crashes
  31. # at the right time.
  32. virecovery=`echo $RECDIR/re*`
  33. if [ "$virecovery" != "$RECDIR/re*" ]; then
  34.     for i in $virecovery; do
  35.         # Only test files that are readable.
  36.         if test ! -r $i; then
  37.             continue
  38.         fi
  39.  
  40.         # Delete any recovery files that are zero length, corrupted,
  41.         # or that have no corresponding backup file.  Else send mail
  42.         # to the user.
  43.         recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
  44.         if test -n "$recfile" -a -s "$recfile"; then
  45.             $SENDMAIL -t < $i
  46.         else
  47.             rm $i
  48.         fi
  49.     done
  50. fi
  51.