home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1580 / dupalias < prev    next >
Encoding:
Text File  |  1990-12-28  |  944 b   |  29 lines

  1. #! /usr/local/bin/perl
  2. #
  3. # Usage: dupalias
  4. # dupalias produces a sorted file containing the contents of the real2alias
  5. # database, then scans it for adjacent lines containing the same alias. It
  6. # reports duplicate aliases on stdout. When it is finished, it deletes the
  7. # file containing the sorted database records.
  8. #
  9. # You should probably run dupalias once a day to make sure nothing has
  10. # gotten screwed up in the alias assignment area. The only time this happened
  11. # to me was because I deleted the lock file when unspool was running, and
  12. # a second one started up, resulting in a dozen duplicate aliases, which
  13. # were subsequently lost.
  14.  
  15. umask 0077;
  16. system("/usr/personals/listr2a | sort >sorted");
  17. open(SORTED,"<sorted") || die "can't open sorted: $!\n";
  18.  
  19. $prevalias = '';
  20. while (<SORTED>) {
  21.     ($key,$value) = split(/:/);
  22.     if ( "$key" eq "$prevalias") {
  23.         print "duplicate alias: $key\n";
  24.     }
  25.     $prevalias = $key;
  26. }
  27. unlink("sorted");
  28. exit(0);
  29.