home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3610 < prev    next >
Encoding:
Internet Message Format  |  1991-07-11  |  5.2 KB

  1. From: hendrik@cca.vu.nl (Hendrik te Winkel)
  2. Newsgroups: alt.binaries.pictures.d,alt.sources
  3. Subject: postlargefile - a shell script for free
  4. Message-ID: <1991Jul10.133302.1324@cca.vu.nl>
  5. Date: 10 Jul 91 13:33:02 GMT
  6.  
  7. Hello netlanders!
  8. This is a contribution I thought I might share with you.
  9. It is a shell script developed by myself to (originally) post a large
  10. file (eg GIF-file) on to the net, with nnpost.
  11.  
  12. It has undoubtedly some drawbacks, some of them are already listed in the script.
  13. One is that it is a C-Shell script, but what the heck, if it is usefull.
  14.  
  15. It is intended to be used with nnpost, since that is the poster I use. I don't
  16. know if it works with other posters, it must be, I guess, it expects a poster
  17. program that can have everything it needs on the argument line, so now
  18. interactivity should be needed.
  19. What else? It does not set paths, it expects split and uuencode and cp and rm
  20. to be accessible, not good, but fix it yourself please.
  21.  
  22. The script works fine here, the call is:
  23. postlarge giffilename subject newsgroup infofilenaam [destribution]
  24. Where the infofilename is the name of the file which will be in the first
  25. part of the posting. The other parts will be the uuencoded splits only.
  26.  
  27. Last thing I tried was to refrain from the signature file to be sent in the
  28. postings, I only wanted the file to appear in the last one, but that didn't
  29. work out fine because nnpost puts things in a queue and I just renamed the
  30. signature file during the execution of this script, alas.
  31.  
  32. Well, here it comes, have fun, and let me know if it is any good, please.
  33.  
  34. Bye, Hendrik
  35. hendrik@cca.vu.nl
  36. ------------------------Shell script to follow, no shar or whatever--------
  37. #!/bin/csh
  38. # Call: postgif giffilename subject newsgroup infofilenaam [destribution]
  39. # This shell script is meant to post (large) files to the specified newsgroup(s).
  40. # It does some controlling and calls a few other programs before the final task:
  41. # Posting by calling nnpost with the appropriate parameters.
  42. # No garantuees, beware that there is no path variabel set.
  43. #
  44. # Hendrik, July, 10th, 1991.
  45.  
  46. # It is intended to be used with nnpost, since that is the poster I use. I don't
  47. # know if it works with other posters, it must be, I guess, it expects a poster
  48. # program that can have everything it needs on the argument line, so now
  49. # interactivity should be needed.
  50. # What else? It does not set paths, it expects split and uuencode and cp and rm
  51. # to be accessible, not good, but fix it yourself please.
  52.  
  53. # The script works fine here, the call is:
  54. # postlarge giffilename subject newsgroup infofilenaam [destribution]
  55. # Where the infofilename is the name of the file which will be in the first
  56. # part of the posting. The other parts will be the uuencoded splits only.
  57.  
  58. # Last thing I tried was to refrain from the signature file to be sent in the
  59. # postings, I only wanted the file to appear in the last one, but that didn't
  60. # work out fine because nnpost puts things in a queue and I just renamed the
  61. # signature file during the execution of this script, alas.
  62.  
  63. # Set the variabels. Note: Try to keep the variabels in your homedir, since
  64. # nnpost uses /usr/tmp already.
  65. # (Which by SunOS is standard linked to /var/tmp, which is on the root device.)
  66.  
  67. set dumpfile = dump            # actual file to be sent
  68. set uuencodefile = uue.out        # output for uuencode
  69. set sumfile = sum.out            # idem for sum
  70.  
  71. # Argument checking
  72.  
  73. if ( $#argv < 4 ) then
  74.     echo "Usage: $0 Gif-filename Subject Newsgroup Info-filename [destribution]"
  75.     exit
  76. endif
  77.  
  78. if (! -f $1 ) then
  79.     echo "Can't find $1"
  80.     echo "Usage: $0 Gif-filename Subject Newsgroup Info-filename [destribution]"
  81.     exit
  82. else if (! -f $4 ) then
  83.     echo "Can't find $4"
  84.     echo "Usage: $0 Gif-filename Subject Newsgroup Info-filename [destribution]"
  85.     exit
  86. else
  87.     if ( $#argv == "5" ) then    # Check if other destribution wanted
  88.         set destrib = $5
  89.     else set destrib = world    # Nope, use world
  90.     endif
  91.  
  92.     # Now remove old files, if any, and create the files that are going to be sent
  93.     rm -f $uuencodefile xa? $sumfile $dumpfile
  94.  
  95.     echo "Sum of the original file:        `sum $1` $1" > $sumfile
  96.     echo "" >> $sumfile
  97.  
  98.     uuencode $1 $1 > $uuencodefile
  99.     split  $uuencodefile
  100.     rm $uuencodefile
  101. endif
  102.  
  103. # Count the number of files to be sent, mind you, I only take the first 26. (xaa-xaz)
  104. # This should be enough, larger postings should be 'junked'.
  105.  
  106. foreach i ( xa? )
  107. @ j ++
  108. end
  109.  
  110. echo Number of files to post: $j
  111.  
  112. # The real loop, take the individual splitted files, do some housekeeping and sent.
  113.  
  114. foreach i ( xa? )
  115. @ k ++
  116. if ( $k == "1" ) then
  117.     echo "Inserting $4 at beginning."
  118.     cat $4 > $dumpfile
  119.     echo "" >> $dumpfile
  120.     cat $sumfile >> $dumpfile
  121.     echo "" >> $dumpfile
  122. else
  123.     cp /dev/null $dumpfile
  124. endif
  125.  
  126.  
  127. echo "------------BEGIN (part $k/$j) CUT HERE----------">>$dumpfile
  128. cat $i >> $dumpfile
  129. echo "--------------END (part $k/$j) CUT HERE----------">>$dumpfile
  130.  
  131. # Now post it, I really do not know if this will work with other posters,
  132. # nnpost -p delivers it rightaway, without editting the files, which is
  133. # exactly as I wanted.
  134.  
  135. nnpost -d $destrib -s "$2 (part $k/$j)" -k " " -y " " -f $dumpfile -p $3
  136.  
  137. end
  138.  
  139. rm xa? $dumpfile
  140. ------------------------end of shell script------------------------------------
  141. -- 
  142. Hendrik te Winkel hendrik@cca.vu.nl
  143.     I don't want no one crying, or feeling sad,
  144.     or standing in the rain without their hat.
  145.     - Chi Coltrane.
  146.