home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume05 / savemap.nwk < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  2.8 KB

  1. From decwrl!ucbvax!agate!eos!ames!nrl-cmf!mailrus!cwjcc!hal!ncoast!allbery Sun Nov 27 00:29:47 PST 1988
  2. Article 734 of comp.sources.misc:
  3. Path: granite!decwrl!ucbvax!agate!eos!ames!nrl-cmf!mailrus!cwjcc!hal!ncoast!allbery
  4. From: gore@eecs.UUCP (Jacob Gore)
  5. Newsgroups: comp.sources.misc
  6. Subject: v05i058: A safe comp.mail.maps saver
  7. Message-ID: <8811251934.aa26419@gamma.eecs.nwu.edu>
  8. Date: 26 Nov 88 04:42:57 GMT
  9. Sender: allbery@ncoast.UUCP
  10. Reply-To: gore@eecs.UUCP (Jacob Gore)
  11. Lines: 108
  12. Approved: allbery@ncoast.UUCP
  13.  
  14. Posting-number: Volume 5, Issue 58
  15. Submitted-by: "Jacob Gore" <gore@eecs.UUCP>
  16. Archive-name: savemap.nawk
  17.  
  18. [Wants the "new" awk.  I'll probably translate it myself later.  ++bsa]
  19.  
  20. # This is a shell archive.  Remove anything before this line,
  21. # then unpack it by saving it in a file and typing "sh file".
  22. #
  23. # Wrapped by gore at gamma.eecs.nwu.edu on Fri Nov 25 19:32:52 1988
  24. #
  25. # This archive contains:
  26. #    README    savemap    
  27. #
  28.  
  29. echo x - README
  30. cat >README <<'@EOF'
  31. This sh/awk script can be used to safely save map shars posted to
  32. comp.mail.maps in some directory.  It does not execute the shars, but
  33. extracts the map files from them.
  34.  
  35. It has hard-wired "knowledge" of what the current official map shars look
  36. like.  On the down side, this means that should the format ever change,
  37. this script will probably have to be changed too.  On the up side, the
  38. worst some joker can do is overwrite your maps with junk or with fake maps.
  39. The script does not even attempt to verify the poster of the shar.
  40.  
  41. It uses the new awk (as described in whe A., W. & K. book).
  42.  
  43. To configure it, modify the "Customization:" paragraph near the beginning
  44. of the script.
  45.  
  46. To use it, just pipe an article from comp.mail.maps into it.  This can be
  47. done automatically, by having your system send news to a fake host (such as
  48. "uumap") and use this script as the command for transmission.
  49.  
  50. Jacob Gore                Gore@EECS.NWU.Edu
  51. Northwestern Univ., EECS Dept.        {oddjob,gargoyle,att}!nucsrl!gore
  52. @EOF
  53.  
  54. chmod 644 README
  55.  
  56. echo x - savemap
  57. cat >savemap <<'@EOF'
  58. #!/bin/sh -
  59. PATH=/bin
  60. IFS="     
  61. "
  62.  
  63. # Saves a map posting from comp.mail.maps in directory MapDir (specified
  64. # below).
  65. #
  66. # Jacob Gore <gore@eecs.nwu.edu> 88/11/25
  67.  
  68. # Customization:
  69. MapDir=/usr/uumap
  70. Awk=/usr/local/bin/nawk
  71. Cd=cd
  72. Mv=/bin/mv
  73. Rm=/bin/rm
  74.  
  75. TMP=tmp$$; export TMP
  76.  
  77. $Cd $MapDir
  78.  
  79. destination=`$Awk '
  80.  
  81. BEGIN {
  82.     while ($1 != "cat" && $2 != "<<" && $4 != ">") {
  83.         getline;
  84.     }
  85.     split($3, tmp_array, "'\''");
  86.     end_marker = tmp_array[2];
  87.     destination = $5;
  88.     "echo $TMP" | getline temp_file
  89.     exit_status = 1;
  90. }
  91.  
  92. $1 == end_marker {
  93.     print destination
  94.     exit_status = 0;
  95.     exit(exit_status);
  96. }
  97.  
  98. {
  99.     print > temp_file
  100. }
  101.  
  102. END {
  103.     exit(exit_status);
  104. }
  105. '`
  106. status=$?
  107.  
  108. if [ $status -eq 0 ]
  109. then
  110.     $Mv -f $TMP $destination
  111.     exit 0
  112.  
  113. else
  114.     $Rm -f $TMP
  115.     exit $status
  116. fi
  117. @EOF
  118.  
  119. chmod 755 savemap
  120.  
  121. exit 0
  122.  
  123.  
  124.