home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume28 / bmw-5 / part01 / ledit < prev    next >
Text File  |  1994-07-09  |  887b  |  54 lines

  1. #! /usr/bin/perl
  2. #
  3. # List Editor ledit/dedit
  4. #
  5. # Edit the mailing list in a safe manner.
  6. #
  7.  
  8. $USAGE = "$0 <list>";
  9.  
  10. if ($#ARGV < 0) {
  11.   print "USAGE: $USAGE\n";
  12.   exit(-1);
  13. }
  14.  
  15. $EDITOR = "/usr/bin/vi";
  16. $SDIR = "/home/bmw";
  17. $EDITDIGEST = 0;
  18. $LISTNAME = $ARGV[0];
  19. if ($LISTNAME eq "-d") {
  20.   $EDITDIGEST = 1;
  21.   shift;
  22.   $LISTNAME = $ARGV[0];
  23. }
  24. $LISTNAME =~ tr/A-Z/a-z/;
  25.  
  26. $LISTDIR = $SDIR . "/" . $LISTNAME;
  27. if (! -d $LISTDIR) {
  28.   print "I can't find $LISTDIR\n";
  29.   exit(-2);
  30. }
  31.  
  32. $LISTFILE = $LISTDIR . "/subscribers";
  33. $LISTFILE = $LISTFILE . ".d" if ($EDITDIGEST);
  34.  
  35. if (! -e $LISTFILE) {
  36.   print "I can't file $LISTFILE\n";
  37.   exit(-3);
  38. }
  39.  
  40. $LOCKFILE = $LISTFILE . ".LOCK";
  41.  
  42. if (-e $LOCKFILE) {
  43.   print "$LISTFILE is currently locked by some other process.\n";
  44.   exit(-4);
  45. }
  46.  
  47. system("touch $LOCKFILE");
  48. system("$EDITOR $LISTFILE");
  49. system("rm $LOCKFILE");
  50. print "Have a nice day.\n";
  51. exit(0);
  52.  
  53.  
  54.