home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume5 / savemap.nawk < prev    next >
Encoding:
Text File  |  1989-02-03  |  2.6 KB  |  120 lines

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