home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume4 / delsub < prev    next >
Text File  |  1989-02-03  |  3KB  |  88 lines

  1. Path: xanth!mcnc!gatech!bloom-beacon!husc6!linus!necntc!ncoast!allbery
  2. From: michael@stb.UUCP (Michael)
  3. Newsgroups: comp.sources.misc
  4. Subject: v04i003: Delsub -- delete a sites subscription to a newsgroup
  5. Message-ID: <10484@stb.UUCP>
  6. Date: 2 Aug 88 01:17:33 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: michael@stb.UUCP (Michael)
  9. Organization: STB BBS, La, Ca, Usa, +1 213 459 7231
  10. Lines: 75
  11. Approved: allbery@ncoast.UUCP
  12.  
  13. Posting-number: Volume 4, Issue 3
  14. Submitted-by: "Michael" <michael@stb.UUCP>
  15. Archive-name: delsub
  16.  
  17. This program implements the "delsub" control message defined as unimplemented
  18. in news 2.11. Specifically, this program will modify the sys file to delete
  19. the subscription, but it is not (yet) called by the news program itself.
  20. (That will have to wait for patch 15)
  21.  
  22. Usage: delsub site group
  23. ex: delsub uunet test.test
  24.             Michael
  25. Note: Do Not Use This To Delete A Subscription For Your Own Site
  26.     (the Me:all line), It Will Not Work.
  27. : hand shar, use sh
  28. # this comment is for some unshar's, the next for others
  29. #! /bin/sh
  30. cat > delsub <<\E*O*F
  31. : /bin/sh
  32. : Program to delete a subscription to a newsgroup for a site.
  33. site=$1
  34. group=$2
  35. cat >> /tmp/sub.$$ << END
  36. BEGIN {FS=":"}
  37. /^$site/ {
  38. END
  39. cat >> /tmp/sub.$$ << \END
  40.     count = split ($0, array, ":");
  41. END
  42. cat >> /tmp/sub.$$ << END
  43.     if (count == 1)    
  44.         {state=1; print; next}
  45.     if (count == 3)
  46.         {state=3; printf ("%s:%s,!%s:%s\n", array[1],array[2],"$group",array[3]);
  47.         next}
  48.     if (count == 4)
  49.         {state = 3; printf ("%s:%s,!%s:%s:%s\n", array[1],array[2],"$group",array[3],array[4]);
  50.         next}
  51.     if (count == 2)
  52.         #Here we have a toughie. The second field must be modified,
  53.         #but there is a \ at the end. Lets assume we can put our
  54.         #thing on the next line.
  55.         {print; print "    !" "$group" ",\\\\" ;state=3; next}
  56. }
  57. state == 1 {
  58. # Here if the first line only declared the site name, and nothing else.
  59. END
  60. cat >> /tmp/sub.$$ << \END
  61.     count = split ($0, array, ":");
  62. END
  63. cat >> /tmp/sub.$$ << END
  64.     if (count == 0) 
  65.         # Boy, are things screwed.
  66.             {state=3; next}
  67.     if (count == 1)
  68.         {print; print "!" "$group" ",\\\\" ; state=3; next}
  69.     if (count > 1)
  70.         {state=3; printf ("%s,!%s:%s\n",array[1],"$group",array[2],array[3]);
  71.         next}
  72. }
  73.  
  74. state == 3 {print}
  75. state == 0 {print}
  76. END
  77.  
  78.  
  79. awk -f /tmp/sub.$$ /usr/lib/news/sys > /tmp/sys.$$
  80. mv /usr/lib/news/sys /usr/lib/news/sys.old
  81. mv /tmp/sys.$$ /usr/lib/news/sys
  82. E*O*F
  83. : --- 
  84. : Michael Gersten             uunet.uu.net!denwa!stb!michael
  85. :                sdcsvax!crash!gryphon!denwa!stb!michael
  86. : What would have happened if we had lost World War 2. Well, the west coast
  87. : would be owned by Japan, we would all be driving foreign cars, hmm...
  88.