home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume30 / bintools / part01 next >
Text File  |  1992-05-30  |  45KB  |  1,533 lines

  1. Newsgroups: comp.sources.misc
  2. From: rthomson@dsd.es.com (Rich Thomson)
  3. Subject:  v30i023:  bintools - binary mail/post tools, Part01/01
  4. Message-ID: <1992May29.203930.973@sparky.imd.sterling.com>
  5. X-Md4-Signature: 7ce6601c5dc6ee2bb5f00a40393183c2
  6. Date: Fri, 29 May 1992 20:39:30 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: rthomson@dsd.es.com (Rich Thomson)
  10. Posting-number: Volume 30, Issue 23
  11. Archive-name: bintools/part01
  12. Environment: UNIX
  13. Supersedes: bintools: Volume 26, Issue 73
  14.  
  15. Trading binary files (i.e. images) has become quite popular on the net.
  16. These are a couple of tools I wrote to sanely post/mail binary
  17. files.  The files are uuencoded and split into pieces.  Each piece is
  18. packaged as a self-extracting shell archive.  Simple BEGIN/END
  19. markers delineating the end/beginning of header/footer material,
  20. respectively, are inserted for those without unshar capabilities.  
  21.  
  22. This gives a way of posting images that is backward compatible with
  23. the current convention (using BEGIN/END markers to delineate
  24. header/footers), while giving those with 'unshar' capabilities
  25. automatic decoding.  Further, decoding with the shell archive allows
  26. the pieces to be processed in any order.
  27.  
  28. This the first major revision of these scripts based on user feedback
  29. after an initial distribution on alt.sources.  New features of the
  30. 2.0 release of these scripts are:
  31.  
  32. Man pages
  33.     The first release was the scripts only.  Troff-source for man pages
  34.     is now included.
  35.  
  36. New flags:
  37.     -N count    Specify size of uuencoded chunks
  38.     -S sleep    Sleep between messages (useful for sluggish transport
  39.         systems)
  40.     -F file    Specify the name of the decoded file when processing
  41.         standard input.
  42.     -sysv
  43.     -bsd    Specify convention of your mail program
  44.     -k        Allows a copy of constructed messages to be stashed away
  45.     -nosend    Doesn't actually deliver the constructed messages
  46.         (useful for testing when combined with -k)
  47.  
  48. Improved shar header
  49.     Better instructions for decoding the shell archives is put into
  50.     the archive header prepended to each piece.  This includes
  51.     instructions for this without /bin/sh (or unix) capabilities.
  52.  
  53.                         -- Rich
  54. ---------------- Cut Here --------------
  55. #! /bin/sh
  56. # This is a shell archive.  Remove anything before this line, then unpack
  57. # it by saving it into a file and typing "sh file".  To overwrite existing
  58. # files, type "sh file -c".  You can also feed this as standard input via
  59. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  60. # will see the following message at the end:
  61. #        "End of shell archive."
  62. # Contents:  post-bin mail-bin post-bin.1 mail-bin.1
  63. # Wrapped by rthomson@mesa on Sat May  2 17:53:48 1992
  64. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  65. if test -f 'post-bin' -a "${1}" != "-c" ; then 
  66.   echo shar: Will not clobber existing file \"'post-bin'\"
  67. else
  68. echo shar: Extracting \"'post-bin'\" \(13494 characters\)
  69. sed "s/^X//" >'post-bin' <<'END_OF_FILE'
  70. X#!/bin/sh
  71. X#
  72. X# post-bin -- post a binary file to news
  73. X#
  74. X# $Header: post-bin,v 2.2 92/05/02 17:35:07 rthomson Exp $
  75. X#
  76. X# post-bin [options] [file...]
  77. X#
  78. X# Valid options are:
  79. X#
  80. X# -n newsgroup
  81. X#    Post the binary image to the named newsgroup.  If no newsgroup is
  82. X#    named, the default is alt.binaries.pictures.misc.
  83. X#
  84. X# -f follow-up
  85. X#    Set the "Followup-to:" field in the article to the named
  86. X#    newsgroup.  If none is specified, the default is
  87. X#    alt.binaries.pictures.d
  88. X#
  89. X# -D distribution
  90. X#    Set the "Distribution:" field in the articles to the named value.
  91. X#    The default distribution is world.
  92. X#
  93. X# -d descfile
  94. X#    Use the named file as the description of the image, to be placed
  95. X#    before each piece of the uuencoded file.  If no description file is
  96. X#    named, the user is placed into $EDITOR on a description file.  If
  97. X#    $EDITOR is undefined, vi is used.  Use '-d /dev/null' for no
  98. X#    description (not recommended!)
  99. X#
  100. X# -t append_text
  101. X#    Append the supplied text to the end of the generated subject
  102. X#    strings.  This allows the articles' subjects to be annotated,
  103. X#    e.g. "[640x480, 256-color GIF]".
  104. X# -T prepend_text
  105. X#    Prepend the given text onto the generated subject line.
  106. X#
  107. X# -N count
  108. X#    Specify the size of the uuencoded pieces.  If count is zero, then
  109. X#    a single article will be posted (only recommended for small files).
  110. X#    Default: 1000
  111. X#
  112. X# -k prefix
  113. X#    Keep the constructed messages after delivery.  This is useful
  114. X#    for reposting/resending a single piece that was not delivered.
  115. X#    The constructed messages are placed in the file given by
  116. X#    "prefix" with .# appended, where "#" is the sequence number of the
  117. X#    message.
  118. X#
  119. X# -nosend
  120. X#    Do not actually deliver the messages.  This is useful for recreating a
  121. X#    particular piece of a large number of pieces without sending them all.
  122. X#    It is also useful in testing out the script.
  123. X#
  124. X# -F filename
  125. X#    Decode to specified filename when reading from standard input.
  126. X#
  127. X# -S sleeptime
  128. X#    Sleep the specified number of seconds between articles.
  129. X#
  130. X# -v    Operate verbosely
  131. X# -q    Operate quietly
  132. X#
  133. X# Post-bin reads the named file(s), uuencodes them, and splits the files
  134. X# into pieces, usually 1000 lines or less in length.  Each piece is then
  135. X# posted as a news article containing a shell archive to the named
  136. X# newsgroup(s).  The sleep option is given because some transport
  137. X# mechanisms (notably, sendmail) can become overwhelmed with the number
  138. X# of articles that post-bin can produce for large files.  By sleeping
  139. X# between articles (say 5 seconds per 1000 lines) sent, post-bin allows
  140. X# the transport mechanism to catch up on processing the articles.
  141. X#
  142. X# If each shell archive is fed to the shell, the uuencoded pieces will
  143. X# be extracted from the archive and a rudimentary file lengthe check
  144. X# will be performed on each piece.  Once all the pieces have been
  145. X# extracted, the pieces will be concatenated in their proper order and
  146. X# fed to uudecode.  If the uudecode operation is successful, the pieces
  147. X# will be removed.
  148. X# 
  149. X# If you do not have /bin/sh or run unix, decoding may also be performed
  150. X# by concatenating the pieces (in the proper order) and feeding the result
  151. X# to the command:
  152. X#
  153. X#  sed -e '/^END/,/^BEGIN/d' | uudecode
  154. X#
  155. X# A description of the file, from the named description file or an
  156. X# editing session if none is named, is placed at the beginning of each
  157. X# article.
  158. X#
  159. X# Please send bugs/comments to rthomson@dsd.es.com
  160. X#
  161. X# Rich Thomson, June 3rd, 1991
  162. X#
  163. X#       Copyright 1991 by Evans & Sutherland Computer Corporation,
  164. X#                  Salt Lake City, Utah
  165. X#
  166. X#                  All Rights Reserved
  167. X#
  168. X#     Permission to use, copy, modify, and distribute this software and its
  169. X#    documentation for any purpose and without fee is hereby granted,
  170. X#     provided that the above copyright notice appear in all copies and that
  171. X#    both that copyright notice and this permission notice appear in
  172. X#   supporting documentation, and that the names of Evans & Sutherland not be
  173. X#       used in advertising or publicity pertaining to distribution of the
  174. X#          software without specific, written prior permission.
  175. X#
  176. X#   EVANS & SUTHERLAND  DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  177. X#     INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  178. X#     EVENT SHALL EVANS & SUTHERLAND BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  179. X#  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  180. X#     DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  181. X#    TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  182. X#             PERFORMANCE OF THIS SOFTWARE.
  183. X#
  184. X
  185. X# remove temporary files upon encountering interrupt or quit signal
  186. Xcleanup()
  187. X{
  188. X    rm -f /tmp/xx-$$-* /tmp/$$-description
  189. X    exit 1
  190. X}
  191. Xtrap cleanup 2 3
  192. X
  193. X# Print a stupid usage message and exit with non-zero status.
  194. Xusage()
  195. X{
  196. X    echo
  197. X    echo "Usage (revision $revision):"
  198. X    echo
  199. X    echo "`basename $0` [options] [file ...]"
  200. X    echo
  201. X    echo Valid options are:
  202. X    echo
  203. X    echo "    [-help]            Get this help message"
  204. X    echo "    [-n newsgroup]     Specify destination newsgroup"
  205. X    echo "                       Default: $newsgroup"
  206. X    echo "    [-f followup-to]   Specify followup-to newsgroup"
  207. X    echo "                       Default: $followup"
  208. X    echo "    [-d descfile]      Specify prepared description file"
  209. X    echo "                       Default is to invoke the editor."
  210. X    echo "    [-D distribution]  Specify distribution value"
  211. X    echo "                       Default: $dist"
  212. X    echo "    [-t append_text]   Append the extra text onto the subject line"
  213. X    echo "    [-T prepend_text]  Prepend the extra text onto the subject line"
  214. X    echo "    [-N count]         Split uuencoded file into count size chunks"
  215. X    echo "                       Default: $count"
  216. X    echo "    [-F filename]      Decode to specified file when using stdin"
  217. X    echo "                       Default: $filename"
  218. X    echo "    [-S sleeptime]     Sleep sleeptime seconds between articles."
  219. X    echo "                       Default: $sleeptime"
  220. X    echo "    [-k prefix]        Keep the constructed messages in files whose"
  221. X    echo "                       names are constructed from the given prefix." 
  222. X    echo "    [-nosend]          Do not actually deliver the messages."
  223. X    if [ $verbosity = True ]; then
  224. X    echo "    [-v]               Operate verbosely (default)"
  225. X    echo "    [-q]               Operate quietly"
  226. X    else
  227. X    echo "    [-v]               Operate verbosely"
  228. X    echo "    [-q]               Operate quietly (default)"
  229. X    fi
  230. X    echo
  231. X
  232. X    exit 1
  233. X}
  234. X
  235. X# print a message if the verbose flag is on.
  236. Xverbose()
  237. X{
  238. X    if [ $verbosity = True ]; then
  239. X    echo $*
  240. X    fi
  241. X}
  242. X
  243. X# This produces leading zeros for the part numbers.  NN users are
  244. X# anal-retentive about the subject lines being lexicographically ordered.
  245. Xzeros()
  246. X{
  247. X    case $1 in
  248. X    1 | 2 )
  249. X        echo $part
  250. X    ;;
  251. X    3 )
  252. X        echo 0$part | sed 's/^.*\(..\)$/\1/'
  253. X    ;;
  254. X    4 )
  255. X        echo 00$part | sed 's/^.*\(...\)$/\1/'
  256. X    ;;
  257. X    5 )
  258. X        echo 000$part | sed 's/^.*\(....\)$/\1/'
  259. X    ;;
  260. X    esac
  261. X}
  262. X
  263. X# put the header on the piece.  This includes a little /bin/sh preamble
  264. X# so that the file can be unpacked on the remote end with /bin/sh.
  265. X#
  266. Xheader()
  267. X{
  268. X    cat << _End_of_Header
  269. X#!/bin/sh
  270. X#
  271. X# This is a self-extracting shell archive of the binary file "$file".
  272. X# Created on `date` by `basename $0`, revision $revision.
  273. X#
  274. X# To decode with /bin/sh, remove everything before the /bin/sh and feed
  275. X# each piece as input to /bin/sh.  When all the pieces have been
  276. X# processed, the archive will automatically concatenate the pieces and
  277. X# uudecode them to produce $file.  If successful, it will remove all
  278. X# uuencoded pieces.  Alternatively, the archive(s) may be processed with
  279. X# no editing by the unshar program.
  280. X#
  281. X# If you do not have /bin/sh or unix, you may decode by removing
  282. X# everthing before/after the lines beginning with the word BEGIN/END,
  283. X# respectively, in each piece.  Then concatenate the pieces in the proper
  284. X# order and uudecode.
  285. X#
  286. Xpart=$print_part
  287. Xpfile=`echo $file | sed 's/^\(..........\).*$/\1/'`
  288. Xfile=$file
  289. Xpsize=`wc -c < $1 | sed 's/ //g'`
  290. Xsed -e '/^BEGIN/d' -e '/^END/d' << \End_of_Section > \$pfile.\$part
  291. XBEGIN------------ $file ------------ part $print_part/$num_parts ---
  292. X_End_of_Header
  293. X}
  294. X
  295. X# The /bin/sh trailer.  It does a rudimentary check on the length of
  296. X# the uuencoded piece extracted.  When all the pieces are present, it
  297. X# concatenates them into uudecode.  There is alot of creative shell
  298. X# quoting here.
  299. X#
  300. Xtrailer()
  301. X{
  302. X    echo END-------------- $file ------------ part $print_part/$num_parts ---
  303. X    cat << _End_of_Trailer
  304. XEnd_of_Section
  305. Xsize=\`wc -c \$pfile.\$part | awk '{ print \$1 }'\`
  306. Xif [ \$size != \$psize ]; then
  307. X    echo Length mismatch for uuencoded part \$part \(\$size != \$psize\).
  308. X    exit 1
  309. Xfi
  310. Xecho \$file, part \$part extracted.
  311. X
  312. Xif [ \`echo \$pfile.[0-9]* | wc -w\` = $num_parts ]; then
  313. X    echo All uuencoded parts of \$file extracted, uudecoding...
  314. X    cat \$pfile.* | uudecode
  315. X    if [ \$? -gt 0 ]; then
  316. X    echo Error encountered when uudecoding pieces...
  317. X    exit 1
  318. X    fi
  319. X
  320. X    echo \$file successfully uudecoded.  Removing uuencoded pieces.
  321. X    rm \$pfile.[0-9]*
  322. Xfi
  323. Xexit 0
  324. X_End_of_Trailer
  325. X}
  326. X
  327. X# Construct each message to be posted on stdout.
  328. Xmessage()
  329. X{
  330. X    echo Newsgroups: $newsgroup
  331. X    echo Subject: $prepend$file, part $print_part/$num_parts$append
  332. X    echo Followup-to: $followup
  333. X    echo Distribution: $dist
  334. X    echo ''
  335. X    cat $descfile
  336. X    echo ''
  337. X    header $1
  338. X    cat $1
  339. X    trailer
  340. X}
  341. X
  342. X# Post each chunk of the file with appropriate header lines, description
  343. X# and header/footer pairs.
  344. Xpost_parts()
  345. X{
  346. X    file=$1
  347. X    shift
  348. X    num_parts=$#
  349. X    part=1
  350. X    num_zeros=`echo $num_parts | wc -c`
  351. X    while [ X$1 != X ]; do
  352. X    print_part=`zeros $num_zeros $part`
  353. X    message    $1 > /tmp/xx-$$-article
  354. X    if [ $noSend = True ]; then
  355. X        verbose Preparing $file, part $print_part of $num_parts...
  356. X    else
  357. X        verbose Posting $file, part $print_part of $num_parts...
  358. X        inews -h /tmp/xx-$$-article
  359. X        if [ X$1 != X ]; then
  360. X        sleep $sleeptime
  361. X        fi
  362. X    fi
  363. X    if [ $keep = True ]; then
  364. X        mv /tmp/xx-$$-article $prefix.$print_part
  365. X    fi
  366. X    part=`expr $part + 1`
  367. X    shift
  368. X    done
  369. X}
  370. X
  371. X# uuencode each file, splitting into $count line chunks.  Then post each chunk.
  372. Xsplit_and_post_files()
  373. X{
  374. X    while [ X$1 != X ]; do
  375. X    rm -f /tmp/xx-$$-*
  376. X    file=`basename $1`
  377. X    if [ $count -eq 0 ]; then
  378. X        verbose UUencoding $file...
  379. X        uuencode $1 $file > /tmp/xx-$$-aa
  380. X    else
  381. X        verbose UUencoding and splitting $file...
  382. X        uuencode $1 $file | split -$count - /tmp/xx-$$-
  383. X    fi
  384. X    post_parts $file /tmp/xx-$$-*
  385. X    rm /tmp/xx-$$-*
  386. X    shift
  387. X    done
  388. X}
  389. X
  390. X# make sure we have descfile setup.  If it is not set, then invoke editor
  391. X# on temporary file
  392. Xget_desc_file()
  393. X{
  394. X    if [ X$descfile = X ]; then
  395. X    descfile=/tmp/$$-description
  396. X    touch $descfile
  397. X    $editor $descfile < /dev/tty
  398. X    fi
  399. X}
  400. X
  401. X# make sure description file created by get_desc_file is removed
  402. Xclean_desc_file()
  403. X{
  404. X    if [ $descfile = /tmp/$$-description ]; then
  405. X    rm $descfile
  406. X    fi
  407. X}
  408. X
  409. X# Check for blank or empty specification for required arguments.
  410. Xblank_arg()
  411. X{
  412. X    if [ "X$1" = X ]; then
  413. X    usage
  414. X    fi
  415. X}
  416. X
  417. X# initialize some variables
  418. X# Default newsgroup
  419. Xnewsgroup="alt.binaries.pictures.misc"
  420. X# Default followup newsgroup; default value is set after argument parsing
  421. Xfollowup=""
  422. X# Default distribution
  423. Xdist=world
  424. X# Default description file (none; invoke editor)
  425. Xdescfile=""
  426. X# Default file list (none; use stdin)
  427. Xfiles=""
  428. X# Chunk size
  429. Xcount=1000
  430. X# Don't keep the messages by default
  431. Xkeep=False
  432. Xprefix=""
  433. X# Deliver the messages by default
  434. XnoSend=False
  435. X# Filename to use for uuencoding stdin
  436. Xfilename="binary.data"
  437. X# Initial extra text is empty
  438. Xappend=""
  439. Xprepend=""
  440. X# Operate verbosely by default
  441. Xverbosity=True
  442. X# Don't sleep between parts by default
  443. Xsleeptime=0
  444. X# Revision of this script.
  445. Xrevision=`echo $Revision: 2.2 $ | sed 's%[^0-9.]%%g'`
  446. Xif [ "X$EDITOR" = "X" ]; then
  447. X    editor=vi
  448. Xelse
  449. X    editor="$EDITOR"
  450. Xfi
  451. X
  452. X# parse the command line arguments
  453. Xwhile [ "X$1" != X ]; do
  454. X    case $1 in
  455. X    -h* )
  456. X        usage
  457. X    ;;
  458. X
  459. X    -t* )
  460. X        append=" $2"
  461. X        blank_arg $2
  462. X        shift
  463. X    ;;
  464. X
  465. X    -T* )
  466. X        prepend="$2 "
  467. X        blank_arg $2
  468. X        shift
  469. X    ;;
  470. X
  471. X    -k* )
  472. X        keep=True
  473. X        prefix=$2
  474. X        blank_arg $prefix
  475. X        shift
  476. X    ;;
  477. X
  478. X    -nosend* )
  479. X        noSend=True
  480. X    ;;
  481. X
  482. X    -n* )
  483. X        newsgroup=$2
  484. X        blank_arg $newsgroup
  485. X        shift
  486. X    ;;
  487. X
  488. X    -f* )
  489. X        followup=$2
  490. X        blank_arg $followup
  491. X        shift
  492. X    ;;
  493. X
  494. X    -D*)
  495. X        dist=$2
  496. X        blank_arg $dist
  497. X        shift
  498. X    ;;
  499. X
  500. X    -d* )
  501. X        descfile=$2
  502. X        blank_arg $descfile
  503. X        shift
  504. X    ;;
  505. X
  506. X    -N* )
  507. X        count=$2
  508. X        blank_arg $count
  509. X        shift
  510. X    ;;
  511. X
  512. X    -F* )
  513. X        filename="$2"
  514. X        blank_arg $filename
  515. X        shift
  516. X    ;;
  517. X
  518. X    -q* )
  519. X        verbosity=False
  520. X    ;;
  521. X
  522. X    -v* )
  523. X        verbosity=True
  524. X    ;;
  525. X
  526. X    * )
  527. X        if [ -r $1 ]; then
  528. X        if [ "X$files" = X ]; then
  529. X            files=$1
  530. X        else
  531. X            files="$files $1"
  532. X        fi
  533. X        else
  534. X        echo `basename $0`: can\'t read file $1.
  535. X        usage
  536. X        fi
  537. X    ;;
  538. X    esac
  539. X    shift
  540. Xdone
  541. X
  542. X# make sure followup is set to something decent if not yet specified
  543. Xif [ "X$followup" = "X" ]; then
  544. X    followup="alt.binaries.pictures.d"
  545. Xfi
  546. X
  547. X# uuencode and split stdin, then post; or split and post file list
  548. Xif [ "X$files" = X ]; then
  549. X    if [ $count -eq 0 ]; then
  550. X    verbose UUencoding standard input as $filename...
  551. X    uuencode $filename > /tmp/xx-$$-aa
  552. X    else
  553. X        verbose UUencoding and splitting standard input as $filename...
  554. X        uuencode $filename | split -$count - /tmp/xx-$$-
  555. X    fi
  556. X    get_desc_file
  557. X    post_parts $filename /tmp/xx-$$-*
  558. X    clean_desc_file
  559. Xelse
  560. X    get_desc_file
  561. X    split_and_post_files $files
  562. X    clean_desc_file
  563. Xfi
  564. X
  565. Xexit 0
  566. END_OF_FILE
  567. if test 13494 -ne `wc -c <'post-bin'`; then
  568.     echo shar: \"'post-bin'\" unpacked with wrong size!
  569. fi
  570. chmod +x 'post-bin'
  571. # end of 'post-bin'
  572. fi
  573. if test -f 'mail-bin' -a "${1}" != "-c" ; then 
  574.   echo shar: Will not clobber existing file \"'mail-bin'\"
  575. else
  576. echo shar: Extracting \"'mail-bin'\" \(12762 characters\)
  577. sed "s/^X//" >'mail-bin' <<'END_OF_FILE'
  578. X#!/bin/sh
  579. X#
  580. X# mail-bin -- mail a binary file to someone
  581. X#
  582. X# $Header: mail-bin,v 2.5 92/05/02 17:53:02 rthomson Exp $
  583. X#
  584. X# mail-bin [options] address [file ...]
  585. X#
  586. X# Valid options are:
  587. X#
  588. X# -d descfile
  589. X#    Use the named file as the description of the image, to be placed
  590. X#    before each piece of the uuencoded file.  If no description file is
  591. X#    named, the user is placed into $EDITOR on a description file.  If
  592. X#    $EDITOR is undefined, vi is used.
  593. X#
  594. X# -t append_text
  595. X#    Append the given text onto the Subject: line.
  596. X# -T prepend_text
  597. X#    Prepend the given text onto the Subject: line.
  598. X#
  599. X# -sysv
  600. X#    Use System V style mailer where Subject: line is the first line in
  601. X#    the body of the message instead of being specified with "-s"
  602. X# -bsd
  603. X#    Use BSD style mailer where Subject: line is given via "-s" switch.
  604. X#
  605. X# -N count
  606. X#    Split file into uuencoded pieces count lines long.
  607. X#
  608. X# -k prefix
  609. X#    Keep the constructed messages after delivery.  This is useful
  610. X#    for reposting/resending a single piece that was not delivered.
  611. X#    The constructed messages are placed in the file given by
  612. X#    "prefix" with .# appended, where "#" is the sequence number of the
  613. X#    message.
  614. X#
  615. X# -nosend
  616. X#    Do not actually deliver the messages.  This is useful for recreating a
  617. X#    particular piece of a large number of pieces without sending them all.
  618. X#    It is also useful in testing out the script.
  619. X#
  620. X# -F filename
  621. X#    Decode to specified filename when reading from standard input.
  622. X#
  623. X# -S sleeptime
  624. X#    Sleep the specified number of seconds between messages.
  625. X#
  626. X# address
  627. X#    The mailing address of the person to receive the binary file.
  628. X#
  629. X# Mail-bin reads the named files, or the standard input if no files are
  630. X# named, and splits the files into 1000 line pieces.  Each piece is then
  631. X# mailed as a to the named recipient as a shell archive.  The sleep
  632. X# option is given because some mailers (notably, sendmail) can become
  633. X# overwhelmed with the number of mail messages that mail-bin can produce
  634. X# for large files.  By sleeping between messages (say 5 seconds per 1000
  635. X# lines) sent, mail-bin allows the mailer to catch up on processing then
  636. X# messages.
  637. X#
  638. X# If each shell archive is fed to the shell, the uuencoded pieces will
  639. X# be extracted from the archive and a rudimentary file length check will
  640. X# be performed on each piece.  Once all the pieces have been extracted,
  641. X# the pieces will be concatenated in their proper order and fed to
  642. X# uudecode.  If the uudecode operation is successful, the pieces will be
  643. X# removed.  Decoding may also be performed by concatenating the pieces
  644. X# (in the proper order) and feeding the result to the command:
  645. X#
  646. X#  sed -e '/^END/,/^BEGIN/d' | uudecode
  647. X#
  648. X# A description of the file, from the named description file or an
  649. X# editing session if none is named, is placed at the beginning of each
  650. X# message.
  651. X#
  652. X# Please send bugs/comments to rthomson@dsd.es.com
  653. X#
  654. X# Rich Thomson, June 28th, 1991
  655. X#
  656. X#       Copyright 1991 by Evans & Sutherland Computer Corporation,
  657. X#                  Salt Lake City, Utah
  658. X#
  659. X#                  All Rights Reserved
  660. X#
  661. X#     Permission to use, copy, modify, and distribute this software and its
  662. X#    documentation for any purpose and without fee is hereby granted,
  663. X#     provided that the above copyright notice appear in all copies and that
  664. X#    both that copyright notice and this permission notice appear in
  665. X#   supporting documentation, and that the names of Evans & Sutherland not be
  666. X#       used in advertising or publicity pertaining to distribution of the
  667. X#          software without specific, written prior permission.
  668. X#
  669. X#   EVANS & SUTHERLAND  DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  670. X#     INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  671. X#     EVENT SHALL EVANS & SUTHERLAND BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  672. X#  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  673. X#     DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  674. X#    TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  675. X#             PERFORMANCE OF THIS SOFTWARE.
  676. X#
  677. X
  678. X# remove temporary files upon encountering interrupt or quit signal
  679. Xcleanup()
  680. X{
  681. X    rm -f /tmp/xx-$$-* /tmp/$$-description
  682. X    exit 1
  683. X}
  684. Xtrap cleanup 2 3
  685. X
  686. X# Stupid usage message
  687. Xusage()
  688. X{
  689. X    echo
  690. X    echo "Usage (revision $revision):"
  691. X    echo
  692. X    echo `basename $0` [options] address [file ...]
  693. X    echo
  694. X    echo Valid options are:
  695. X    echo
  696. X    echo "    [-help]            Get this help message"
  697. X    echo "    [-d descfile]      Specify prepared description file"
  698. X    echo "                       Default is to invoke the editor."
  699. X    echo "    [-t append_text]   Append the extra text onto the subject line"
  700. X    echo "    [-T prepend_text]  Prepend the extra text onto the subject line"
  701. X    echo "    [-N count]         Split file into pieces of count lines"
  702. X    echo "                       Default: $count"
  703. X    echo "    [-F filename]      Decode to specified file when using stdin"
  704. X    echo "                       Default: $filename"
  705. X    echo "    [-S sleeptime]     Sleep sleeptime seconds between messages."
  706. X    echo "                       Default: $sleeptime"
  707. X    echo "    [-k prefix]        Keep the constructed messages in files whose"
  708. X    echo "                       names are constructed from the given prefix." 
  709. X    echo "    [-nosend]          Do not actually deliver the messages."
  710. X    if [ $systemV = True ]; then
  711. X    echo "    [-sysv]            mail program is System V style (default)"
  712. X    echo "    [-bsd]             mail program is BSD style"    
  713. X    else
  714. X    echo "    [-sysv]            mail program is System V style"
  715. X    echo "    [-bsd]             mail program is BSD style (default)"
  716. X    fi
  717. X    if [ $verbosity = True ]; then
  718. X    echo "    [-v]               Operate verbosely (default)"
  719. X    echo "    [-q]               Operate quietly"
  720. X    else
  721. X    echo "    [-v]               Operate verbosely"
  722. X    echo "    [-q]               Operate quietly (default)"
  723. X    fi
  724. X    echo
  725. X    exit 1
  726. X}
  727. X
  728. X# print a message if the verbose flag is on.
  729. Xverbose()
  730. X{
  731. X    if [ $verbosity = True ]; then
  732. X    echo $*
  733. X    fi
  734. X}
  735. X
  736. X# This produces leading zeros for the part numbers.  NN users are
  737. X# anal-retentive about the subject lines being lexicographically ordered.
  738. Xzeros()
  739. X{
  740. X    case $1 in
  741. X    1 | 2 )
  742. X        echo $part
  743. X    ;;
  744. X    3 )
  745. X        echo 0$part | sed 's/^.*\(..\)$/\1/'
  746. X    ;;
  747. X    4 )
  748. X        echo 00$part | sed 's/^.*\(...\)$/\1/'
  749. X    ;;
  750. X    esac
  751. X}
  752. X
  753. X# put the header on the piece.  This includes a little /bin/sh preamble
  754. X# so that the file can be unpacked on the remote end with /bin/sh.
  755. X#
  756. Xheader()
  757. X{
  758. X    cat << _End_of_Header
  759. X#!/bin/sh
  760. X#
  761. X# This is a self-extracting shell archive of the binary file "$file".
  762. X# Created on `date` by `basename $0`, revision $revision.
  763. X#
  764. X# To decode with /bin/sh, remove everything before the /bin/sh and feed
  765. X# each piece as input to /bin/sh.  When all the pieces have been
  766. X# processed, the archive will automatically concatenate the pieces and
  767. X# uudecode them to produce $file.  If successful, it will remove all
  768. X# uuencoded pieces.  Alternatively, the archive(s) may be processed with
  769. X# no editing by the unshar program.
  770. X#
  771. X# If you do not have /bin/sh or unix, you may decode by removing
  772. X# everthing before/after the lines beginning with the word BEGIN/END,
  773. X# respectively, in each piece.  Then concatenate the pieces in the proper
  774. X# order and uudecode.
  775. X#
  776. Xpart=$print_part
  777. Xpfile=`echo $file | sed 's/^\(..........\).*$/\1/'`
  778. Xfile=$file
  779. Xpsize=`wc -c < $1 | sed 's/ //g'`
  780. Xsed -e '/^BEGIN/d' -e '/^END/d' << \End_of_Section > \$pfile.\$part
  781. XBEGIN------------ $file ------------ part $print_part/$num_parts ---
  782. X_End_of_Header
  783. X}
  784. X
  785. X# The /bin/sh trailer.  It does a rudimentary check on the length of
  786. X# the uuencoded piece extracted.  When all the pieces are present, it
  787. X# concatenates them into uudecode.  There is alot of creative shell
  788. X# quoting here.
  789. X#
  790. Xtrailer()
  791. X{
  792. X    echo END-------------- $file ------------ part $print_part/$num_parts ---
  793. X    cat << _End_of_Trailer
  794. XEnd_of_Section
  795. Xsize=\`wc -c \$pfile.\$part | awk '{ print \$1 }'\`
  796. Xif [ \$size != \$psize ]; then
  797. X    echo Length mismatch for uuencoded part \$part \(\$size != \$psize\).
  798. X    exit 1
  799. Xfi
  800. Xecho \$file, part \$part extracted.
  801. X
  802. Xif [ \`echo \$pfile.[0-9]* | wc -w\` = $num_parts ]; then
  803. X    echo All uuencoded parts of \$file extracted, uudecoding...
  804. X    cat \$pfile.* | uudecode
  805. X    if [ \$? -gt 0 ]; then
  806. X    echo Error encountered when uudecoding pieces...
  807. X    exit 1
  808. X    fi
  809. X
  810. X    echo \$file successfully uudecoded.  Removing uuencoded pieces.
  811. X    rm \$pfile.[0-9]*
  812. Xfi
  813. Xexit 0
  814. X_End_of_Trailer
  815. X}
  816. X
  817. X# Create the body of each message
  818. Xbody()
  819. X{
  820. X    if [ $systemV = True ]; then
  821. X    echo To: $address
  822. X    echo  Subject: $prepend$file, part $print_part/$num_parts$append
  823. X    echo ''
  824. X    fi
  825. X    cat $descfile
  826. X    echo ''
  827. X    header $1
  828. X    cat $1
  829. X    trailer
  830. X}
  831. X
  832. X# Post each chunk of the file with appropriate header lines, description
  833. X# and header/footer pairs.
  834. Xmail_parts()
  835. X{
  836. X    file=$1
  837. X    shift
  838. X    num_parts=$#
  839. X    part=1
  840. X    num_zeros=`echo $num_parts | wc -c`
  841. X    while [ X$1 != X ]; do
  842. X    print_part=`zeros $num_zeros $part`
  843. X    verbose Mailing $file, part $print_part of $num_parts...
  844. X    if [ $keep = True ]; then
  845. X        body $1 \
  846. X        | tee $prefix.$print_part
  847. X    else
  848. X        body $1
  849. X    fi \
  850. X    | if [ $noSend = True ]; then
  851. X        cat > /dev/null
  852. X    else
  853. X        if [ $systemV = True ]; then
  854. X        mail $address
  855. X        else
  856. X        mail -s "$prepend$file, part $print_part/$num_parts$append" \
  857. X            $address
  858. X        fi
  859. X        if [ X$1 != X ]; then
  860. X        sleep $sleeptime
  861. X        fi
  862. X    fi
  863. X    part=`expr $part + 1`
  864. X    shift
  865. X    done
  866. X}
  867. X
  868. X# uuencode each file, splitting into $count line chunks.  Then mail each chunk.
  869. Xsplit_and_mail_files()
  870. X{
  871. X    while [ X$1 != X ]; do
  872. X    rm -f /tmp/xx-$$-*
  873. X    file=`basename $1`
  874. X    if [ $count -eq 0 ]; then
  875. X        verbose UUencoding $file...
  876. X        uuencode $1 $file > /tmp/xx-$$-aa
  877. X    else
  878. X        verbose UUencoding and splitting $file...
  879. X        uuencode $1 $file | split -$count - /tmp/xx-$$-
  880. X    fi
  881. X    mail_parts $file /tmp/xx-$$-*
  882. X    rm /tmp/xx-$$-*
  883. X    shift
  884. X    done
  885. X}
  886. X
  887. X# make sure we have descfile setup.  If it is not set, then invoke editor
  888. X# on temporary file
  889. Xget_desc_file()
  890. X{
  891. X    if [ X$descfile = X ]; then
  892. X    descfile=/tmp/$$-description
  893. X    touch $descfile
  894. X    $editor $descfile < /dev/tty
  895. X    fi
  896. X}
  897. X
  898. X# make sure description file created by get_desc_file is removed
  899. Xclean_desc_file()
  900. X{
  901. X    if [ $descfile = /tmp/$$-description ]; then
  902. X    rm $descfile
  903. X    fi
  904. X}
  905. X
  906. X# Check for blank or empty specification for required arguments.
  907. Xblank_arg()
  908. X{
  909. X    if [ "X$1" = X ]; then
  910. X    usage
  911. X    fi
  912. X}
  913. X
  914. X# initialize some variables
  915. X# No address by default; must be specified.
  916. Xaddress=""
  917. X# Invoke editor for description by default
  918. Xdescfile=""
  919. X# Default to stdin.
  920. Xfiles=""
  921. X# Decode into this file when using stdin.
  922. Xfilename="binary.data"
  923. X# No extra text by default
  924. Xappend=""
  925. Xprepend=""
  926. X# Be verbose by default
  927. Xverbosity=True
  928. X# Use 1000 line chunks by default
  929. Xcount=1000
  930. X# Don't keep the messages by default
  931. Xkeep=False
  932. Xprefix=""
  933. X# Deliver the messages by default
  934. XnoSend=False
  935. X# Don't use System V style mailing by default
  936. XsystemV=False
  937. X# Don't sleep between parts by default
  938. Xsleeptime=0
  939. X# Revision of this script
  940. Xrevision=`echo $Revision: 2.5 $ | sed 's%[^0-9.]%%g'`
  941. Xif [ "X$EDITOR" = "X" ]; then
  942. X    editor=vi
  943. Xelse
  944. X    editor="$EDITOR"
  945. Xfi
  946. X
  947. X# parse the command line arguments
  948. Xwhile [ X$1 != X ]; do
  949. X    case $1 in
  950. X    -h* )
  951. X        usage
  952. X    ;;
  953. X
  954. X    -d* )
  955. X        descfile=$2;
  956. X        blank_arg $descfile
  957. X        shift
  958. X    ;;
  959. X
  960. X    -t* )
  961. X        append=" $2"
  962. X        blank_arg $2
  963. X        shift
  964. X    ;;
  965. X
  966. X    -T* )
  967. X        prepend="$2 "
  968. X        blank_arg $2
  969. X        shift
  970. X    ;;
  971. X
  972. X    -N* )
  973. X        count=$2
  974. X        blank_arg $count
  975. X        shift
  976. X    ;;
  977. X
  978. X    -k* )
  979. X        keep=True
  980. X        prefix=$2
  981. X        blank_arg $prefix
  982. X        shift
  983. X    ;;
  984. X
  985. X    -nosend* )
  986. X        noSend=True
  987. X    ;;
  988. X
  989. X    -sysv* )
  990. X        systemV=True
  991. X    ;;
  992. X
  993. X    -bsd* )
  994. X        systemV=False
  995. X    ;;
  996. X
  997. X    -F* )
  998. X        filename="$2"
  999. X        blank_arg $filename
  1000. X        shift
  1001. X    ;;
  1002. X
  1003. X    -S* )
  1004. X        sleeptime="$2";
  1005. X        blank_arg $sleeptime
  1006. X        shift
  1007. X    ;;
  1008. X
  1009. X    -q* )
  1010. X        verbosity=False
  1011. X    ;;
  1012. X
  1013. X    -v* )
  1014. X        verbosity=True
  1015. X    ;;
  1016. X
  1017. X    * )
  1018. X        if [ "X$address" = X ]; then
  1019. X        address=$1
  1020. X        else
  1021. X        if [ -r $1 ]; then
  1022. X            if [ "X$files" = X ]; then
  1023. X            files=$1
  1024. X            else
  1025. X            files="$files $1"
  1026. X            fi
  1027. X        else
  1028. X            echo `basename $0`: can\'t read file $1.
  1029. X            usage
  1030. X        fi
  1031. X        fi
  1032. X    ;;
  1033. X    esac
  1034. X    shift
  1035. Xdone
  1036. X
  1037. X# Must have a mail address before continuing
  1038. Xif [ "X$address" = X ]; then
  1039. X    echo Required address argument missing!
  1040. X    echo
  1041. X    usage
  1042. Xfi
  1043. X
  1044. X# uuencode and split stdin, then mail; or split and mail file list
  1045. Xif [ "X$files" = X ]; then
  1046. X    if [ $count -eq 0 ]; then
  1047. X    verbose UUencoding standard input as $filename...
  1048. X    uuencode $filename > /tmp/xx-$$-aa
  1049. X    else
  1050. X    verbose UUencoding and splitting standard input as $filename...
  1051. X    uuencode $filename | split -$count - /tmp/xx-$$-
  1052. X    fi
  1053. X    get_desc_file;
  1054. X    mail_parts $filename /tmp/xx-$$-*;
  1055. X    clean_desc_file;
  1056. Xelse
  1057. X    get_desc_file;
  1058. X    split_and_mail_files $files;
  1059. X    clean_desc_file;
  1060. Xfi
  1061. X
  1062. Xexit 0
  1063. END_OF_FILE
  1064. if test 12762 -ne `wc -c <'mail-bin'`; then
  1065.     echo shar: \"'mail-bin'\" unpacked with wrong size!
  1066. fi
  1067. chmod +x 'mail-bin'
  1068. # end of 'mail-bin'
  1069. fi
  1070. if test -f 'post-bin.1' -a "${1}" != "-c" ; then 
  1071.   echo shar: Will not clobber existing file \"'post-bin.1'\"
  1072. else
  1073. echo shar: Extracting \"'post-bin.1'\" \(6273 characters\)
  1074. sed "s/^X//" >'post-bin.1' <<'END_OF_FILE'
  1075. X.TH POST-BIN 1 "2 May 1992" "" "Binary Tools"
  1076. X.\"
  1077. X.\"       Copyright 1991 by Evans & Sutherland Computer Corporation,
  1078. X.\"                  Salt Lake City, Utah
  1079. X.\"
  1080. X.\"                  All Rights Reserved
  1081. X.\"
  1082. X.\"   Permission to use, copy, modify, and distribute this software and its
  1083. X.\"    documentation for any purpose and without fee is hereby granted,
  1084. X.\"   provided that the above copyright notice appear in all copies and that
  1085. X.\"    both that copyright notice and this permission notice appear in
  1086. X.\" supporting documentation, and that the names of Evans & Sutherland not be
  1087. X.\"     used in advertising or publicity pertaining to distribution of the
  1088. X.\"          software without specific, written prior permission.
  1089. X.\"
  1090. X.\" EVANS & SUTHERLAND  DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  1091. X.\"   INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  1092. X.\"   EVENT SHALL EVANS & SUTHERLAND BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  1093. X.\" CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  1094. X.\"   DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  1095. X.\"   TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1096. X.\"             PERFORMANCE OF THIS SOFTWARE.
  1097. X.\"
  1098. X.SH NAME
  1099. Xpost-bin \- sanely post a binary file to a newsgroup
  1100. X.SH SYNOPSIS
  1101. X.B post-bin
  1102. X[
  1103. X.BI \-n\  newsgroup
  1104. X]
  1105. X[
  1106. X.BI \-f\  follow-up
  1107. X]
  1108. X[
  1109. X.BI \-D\  distribution
  1110. X]
  1111. X[
  1112. X.BI \-d\  descfile
  1113. X]
  1114. X[
  1115. X.BI \-t\  append_text
  1116. X]
  1117. X[
  1118. X.BI \-T\  prepend_text
  1119. X]
  1120. X[
  1121. X.BI \-N\  count
  1122. X]
  1123. X[
  1124. X.BI \-F\  filename
  1125. X]
  1126. X[
  1127. X.BI \-S\  sleeptime
  1128. X]
  1129. X[
  1130. X.BI \-k\  prefix
  1131. X]
  1132. X[
  1133. X.B \-nosend
  1134. X]
  1135. X[
  1136. X.B \-v
  1137. X]
  1138. X[
  1139. X.B \-q
  1140. X]
  1141. X[
  1142. X.B \-help
  1143. X]
  1144. X[
  1145. X.IR filename .\|.\|.
  1146. X]
  1147. X.LP
  1148. X.SH DESCRIPTION
  1149. X.LP
  1150. X.B Post-bin
  1151. Xreads the named files, or the standard input if no files are named,
  1152. Xuuencodes them, and splits the uuencoded files into pieces.
  1153. XEach piece is then posted as to the named newsgroup as a self-extracting
  1154. Xshell archive.
  1155. X.LP
  1156. XThe reader then feeds the body of each article (the portion beginning
  1157. Xat the #!/bin/sh line) as the standard input to /bin/sh.
  1158. XIf the unshar program is available, it may be used to process each
  1159. Xarticle without any editing.  Some newsreaders (i.e. rn 4.4) also
  1160. Xprovide an "unshar" command that may also be used.
  1161. XThe received articles may be processed in any order (typically
  1162. Xthey do not arrive in the order sent).  Once all pieces of a binary file
  1163. Xhave been processed, the shell archive automatically concatenates the
  1164. Xpieces in their proper order and uudecodes them.  If the file was
  1165. Xsuccessfully uudecoded, the individual pieces are removed.
  1166. X.LP
  1167. XFor those readers without /bin/sh (or not running unix),
  1168. Xdecoding may be performed by removing the all text before/after the
  1169. Xlines beginning with the words BEGIN/END, respectively, in each
  1170. Xpiece.  Then concatenate the pieces in the proper order and uudecode.
  1171. X.LP
  1172. XA description of the file, from the named description file or an
  1173. Xediting session if none is named, is placed at the beginning of each
  1174. Xarticle.
  1175. X.SH OPTIONS
  1176. X.TP
  1177. X.BI \-n\  newsgroup
  1178. XPost the binary file to the named newsgroup.  Default:
  1179. Xalt.binaries.pictures.misc.
  1180. X.TP
  1181. X.BI \-f\  follow-up
  1182. XSet the Followup-To field in the header to the named newsgroup.  Default:
  1183. Xalt.binaries.pictures.d
  1184. X.TP
  1185. X.BI \-D\  distribution
  1186. XSet the Distribution field in the header to the named distribution.
  1187. XDefault: world
  1188. X.TP
  1189. X.BI \-d\  descfile
  1190. XSpecifies a prepared description file.  Use /dev/null for no description.
  1191. XIf
  1192. X.B \-d
  1193. Xis not specified, the user will be placed into the editor specified by the
  1194. XEDITOR evironment variable.  If EDITOR is undefined, vi(1) will be used.
  1195. X.TP
  1196. X.BI \-t\  append_text
  1197. XAppends the given text to the subject line of each
  1198. Xarticle generated.  Be sure to quote the text if it includes spaces.
  1199. X.TP
  1200. X.BI \-T\  prepend_text
  1201. XPrepends the given text to the subject line of each
  1202. Xarticle generated.  Be sure to quote the text if it includes spaces.
  1203. X.TP
  1204. X.BI \-N\  count
  1205. XSpecifies the size, in lines, of the uuencoded pieces.  If the
  1206. Xspecified count is zero, a single article containing the entire
  1207. Xuuencoded file will be sent.  The default is 1000.
  1208. X.TP
  1209. X.BI \-F\  filename
  1210. XWhen uuencoding the standard input, use the specified filename as the
  1211. Xname the file should have when decoded.  The default is the name
  1212. Xbinary.data.  This option is ignored when not processing the standard
  1213. Xinput.
  1214. X.TP
  1215. X.BI \-S\  sleeptime
  1216. XSleep for the given number of seconds between each each posted article
  1217. Xto allow for sluggish article transport systems.
  1218. X.TP
  1219. X.BI \-k\  prefix
  1220. XSpecifies that the constructed messages are to be kept, one per file.
  1221. XThe file name is constructed from the given prefix, a dot, and the
  1222. Xsequence number.  This is useful for keeping the constructed messages
  1223. Xshould a single message from the group need to be reposted.
  1224. X.TP
  1225. X.B \-nosend
  1226. XSpecifies that the constructed messages are not to be delivered.  This
  1227. Xis useful for testing the script in combination with the "keep" option.
  1228. X.TP
  1229. X.B \-v
  1230. XOperate verbosely, printing out progress of the uuencoding and posting of
  1231. Xthe piece.  This is the default.
  1232. X.TP
  1233. X.B \-q
  1234. XOperate quietly.
  1235. X.TP
  1236. X.B \-help
  1237. XPrint out a short summary of options.
  1238. X.SH EXAMPLES
  1239. X.LP
  1240. XWhen testing, it is often useful to post the image to a local newsgroup
  1241. Xwith a limited distribution.  In this example the description file is
  1242. Xgiven as /dev/null, which results in no descriptive text at the
  1243. Xbeginning of each article (not recommended for wide distribution):
  1244. X.IP
  1245. Xpost-bin \-D utah -n utah.test -f utah.test \-d \\
  1246. X/dev/null \-t 'JPEG file of tree bark' bark.jpeg
  1247. X.LP
  1248. X.SH ENVIRONMENT
  1249. X.TP 20
  1250. X.B EDITOR
  1251. XThe name of the editor to use on the description file; defaults to vi.
  1252. X.SH FILES
  1253. X.TP 20
  1254. X.B /tmp/xx-$$-
  1255. XThe name of the split uuencoded pieces, appended with aa, ab, ac, etc.
  1256. X$$ refers to the process id of the shell script.
  1257. X.TP 20
  1258. X.B /tmp/xx-$$-article
  1259. XTemporary file for constructing the article.
  1260. X.TP 20
  1261. X.B /tmp/$$-description
  1262. XTemporary file used to contain the descriptive text.
  1263. X.SH SEE ALSO
  1264. X.BR mail-bin (1),
  1265. X.BR sh (1),
  1266. X.BR uuencode (1),
  1267. X.BR uudecode (1),
  1268. X.BR split (1),
  1269. X.BR unshar (1)
  1270. X.SH AUTHOR
  1271. XRich Thomson <rthomson@dsd.es.com>
  1272. X.br
  1273. XSoftware Engineer
  1274. X.br
  1275. XDesign Systems Division
  1276. X.br
  1277. XEvans & Sutherland Computer Corporation
  1278. X.SH COPYRIGHT
  1279. XCopyright (C) 1991, Evans & Sutherland Computer Corporation
  1280. X.SH DIAGNOSTICS
  1281. X.B Post-bin
  1282. Xwill complain about missing files and perform no action.
  1283. X.SH BUGS
  1284. XNone known.
  1285. END_OF_FILE
  1286. if test 6273 -ne `wc -c <'post-bin.1'`; then
  1287.     echo shar: \"'post-bin.1'\" unpacked with wrong size!
  1288. fi
  1289. # end of 'post-bin.1'
  1290. fi
  1291. if test -f 'mail-bin.1' -a "${1}" != "-c" ; then 
  1292.   echo shar: Will not clobber existing file \"'mail-bin.1'\"
  1293. else
  1294. echo shar: Extracting \"'mail-bin.1'\" \(6632 characters\)
  1295. sed "s/^X//" >'mail-bin.1' <<'END_OF_FILE'
  1296. X.TH MAIL-BIN 1 "2 May 1992" "" "Binary Tools"
  1297. X.\"
  1298. X.\"       Copyright 1991 by Evans & Sutherland Computer Corporation,
  1299. X.\"                  Salt Lake City, Utah
  1300. X.\"
  1301. X.\"                  All Rights Reserved
  1302. X.\"
  1303. X.\"   Permission to use, copy, modify, and distribute this software and its
  1304. X.\"    documentation for any purpose and without fee is hereby granted,
  1305. X.\"   provided that the above copyright notice appear in all copies and that
  1306. X.\"    both that copyright notice and this permission notice appear in
  1307. X.\" supporting documentation, and that the names of Evans & Sutherland not be
  1308. X.\"     used in advertising or publicity pertaining to distribution of the
  1309. X.\"          software without specific, written prior permission.
  1310. X.\"
  1311. X.\" EVANS & SUTHERLAND  DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  1312. X.\"   INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  1313. X.\"   EVENT SHALL EVANS & SUTHERLAND BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  1314. X.\" CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  1315. X.\"   DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  1316. X.\"    TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1317. X.\"             PERFORMANCE OF THIS SOFTWARE.
  1318. X.\"
  1319. X.SH NAME
  1320. Xmail-bin \- sanely mail a binary file to someone
  1321. X.SH SYNOPSIS
  1322. X.B mail-bin
  1323. X[
  1324. X.BI \-d\  descfile
  1325. X]
  1326. X[
  1327. X.BI \-t\  append_text
  1328. X]
  1329. X[
  1330. X.BI \-T\  prepend_text
  1331. X]
  1332. X[
  1333. X.B \-sysv
  1334. X]
  1335. X[
  1336. X.B \-bsd
  1337. X]
  1338. X[
  1339. X.BI \-N\  count
  1340. X]
  1341. X[
  1342. X.BI \-F\  filename
  1343. X]
  1344. X[
  1345. X.BI \-S\  sleeptime
  1346. X]
  1347. X[
  1348. X.BI \-k\  prefix
  1349. X]
  1350. X[
  1351. X.B \-nosend
  1352. X]
  1353. X[
  1354. X.B \-v
  1355. X]
  1356. X[
  1357. X.B \-q
  1358. X]
  1359. X[
  1360. X.B \-help
  1361. X]
  1362. X.I address
  1363. X[
  1364. X.IR filename .\|.\|.
  1365. X]
  1366. X.LP
  1367. X.SH DESCRIPTION
  1368. X.LP
  1369. X.B Mail-bin
  1370. Xreads the named files, or the standard input if no files are named,
  1371. Xuuencodes them, and splits the uuencoded files into pieces.
  1372. XEach piece is then mailed as a to the named recipient as a self-extracting
  1373. Xshell archive.
  1374. X.LP
  1375. XThe recipient then feeds the body of each message (the portion beginning
  1376. Xat the #!/bin/sh line) as the standard input to /bin/sh.
  1377. XIf the unshar program is available, it may be used to process each
  1378. Xmessage without any editing.
  1379. XThe received messages may be processed in any order (typically
  1380. Xthey do not arrive in the order sent).  Once all pieces of a binary file
  1381. Xhave been processed, the shell archive automatically concatenates the
  1382. Xpieces in their proper order and uudecodes them.  If the file was
  1383. Xsuccessfully uudecoded, the individual pieces are removed.
  1384. X.LP
  1385. XFor those without /bin/sh (or not running unix),
  1386. Xdecoding may be performed by removing the all text before/after the
  1387. Xlines beginning with the words BEGIN/END, respectively, in each
  1388. Xpiece.  Then concatenate the pieces in the proper order and uudecode.
  1389. X.LP
  1390. XA description of the file, from the named description file or an
  1391. Xediting session if none is named, is placed at the beginning of each
  1392. Xmessage.
  1393. X.LP
  1394. XWhen sending large amounts of data, it is possible to overwhelm the
  1395. Xlocal mail delivery system (most notably sendmail).  To accomodate for
  1396. Xthis,
  1397. X.B mail-bin
  1398. Xprovides an option to sleep between messages to allow for a sluggish
  1399. Xtransport system.
  1400. X.SH OPTIONS
  1401. X.TP
  1402. X.BI \-d\  descfile
  1403. XSpecifies a prepared description file.  Use /dev/null for no description.
  1404. XIf
  1405. X.B \-d
  1406. Xis not specified, the user will be placed into the editor specified by the
  1407. XEDITOR evironment variable.  If EDITOR is undefined, vi(1) will be used.
  1408. X.TP
  1409. X.BI \-t\  append_text
  1410. XAppends the given text to the subject line of each
  1411. Xarticle generated.  Be sure to quote the text if it includes spaces.
  1412. X.TP
  1413. X.BI \-T\  prepend_text
  1414. XPrepends the given text to the subject line of each
  1415. Xarticle generated.  Be sure to quote the text if it includes spaces.
  1416. X.TP
  1417. X.B \-sysv
  1418. XThis option tells
  1419. X.B mail-bin
  1420. Xthat
  1421. X.BR mail (1)
  1422. Xis a System V style mail program that expects To: and Subject: lines
  1423. Xon its standard input followed by a blank line and then the body of
  1424. Xthe message.
  1425. X.TP
  1426. X.B \-bsd
  1427. XThis option tells
  1428. X.B mail-bin
  1429. Xthat
  1430. X.BR mail (1)
  1431. Xis a BSD style mail program that expects the body of the message on
  1432. Xits standard input with the subject of the message specified with the
  1433. X-s option to
  1434. X.BR mail (1).
  1435. X.B Mail-bin
  1436. Xassumes a BSD style mailer by default.
  1437. X.TP
  1438. X.BI \-N\  count
  1439. XSpecifies the size, in lines, of the uuencoded pieces.  If the
  1440. Xspecified count is zero, a single message containing the entire
  1441. Xuuencoded file will be sent.  The default is 1000.
  1442. X.TP
  1443. X.BI \-F\  filename
  1444. XWhen uuencoding the standard input, use the specified filename as the
  1445. Xname the file should have when decoded.  The default is the name
  1446. Xbinary.data.  This option is ignored when not processing the standard
  1447. Xinput.
  1448. X.TP
  1449. X.BI \-S\  sleeptime
  1450. XSleep for the given number of seconds between each message
  1451. Xto allow for sluggish message transport systems (notably sendmail).
  1452. X.TP
  1453. X.BI \-k\  prefix
  1454. XSpecifies that the constructed messages are to be kept, one per file.
  1455. XThe file name is constructed from the given prefix, a dot, and the
  1456. Xsequence number.  This is useful for keeping the constructed messages
  1457. Xshould a single message from the group need to be reposted.
  1458. X.TP
  1459. X.B \-nosend
  1460. XSpecifies that the constructed messages are not to be delivered.  This
  1461. Xis useful for testing the script in combination with the "keep" option.
  1462. X.TP
  1463. X.B \-v
  1464. XOperate verbosely, printing out progress of the uuencoding and mailing of
  1465. Xthe piece.  This is the default.
  1466. X.TP
  1467. X.B \-q
  1468. XOperate quietly.
  1469. X.TP
  1470. X.B \-help
  1471. XPrint out a short summary of options.
  1472. X.SH EXAMPLES
  1473. X.LP
  1474. XTo mail the binary file bark.jpeg to user baz@frobozz.com with the
  1475. Xannotation subject line "JPEG file of tree bark" and no descriptive text in
  1476. Xthe body of the message:
  1477. X.IP
  1478. Xmail-bin \-d /dev/null \-t 'JPEG file of tree bark' \\
  1479. Xbaz@frobozz.com bark.jpeg
  1480. X.LP
  1481. XTo mail a compressed tar archive of the directory foo to user
  1482. Xbaz@frobozz.com, sleeping 5 seconds between messages:
  1483. X.IP
  1484. Xtar cvf - foo | compress | mail-bin \-d /dev/null -F \\
  1485. Xfoo.tar.Z -S 5 baz@frobozz.com
  1486. X.SH ENVIRONMENT
  1487. X.TP 20
  1488. X.B EDITOR
  1489. XThe name of the editor to use on the description file; defaults to vi.
  1490. X.SH FILES
  1491. X.TP 20
  1492. X.B /tmp/xx-$$-
  1493. XThe name of the split uuencoded pieces, appended with aa, ab, ac, etc.
  1494. X$$ refers to the process id of the shell script.
  1495. X.TP 20
  1496. X.B /tmp/xx-$$-message
  1497. XTemporary file for constructing the message body.
  1498. X.TP 20
  1499. X.B /tmp/$$-description
  1500. XTemporary file used to contain the descriptive text.
  1501. X.SH SEE ALSO
  1502. X.BR post-bin (1),
  1503. X.BR sh (1),
  1504. X.BR uuencode (1),
  1505. X.BR uudecode (1),
  1506. X.BR split (1),
  1507. X.BR unshar (1)
  1508. X.SH AUTHOR
  1509. XRich Thomson <rthomson@dsd.es.com>
  1510. X.br
  1511. XSoftware Engineer
  1512. X.br
  1513. XDesign Systems Division
  1514. X.br
  1515. XEvans & Sutherland Computer Corporation
  1516. X.SH COPYRIGHT
  1517. XCopyright (C) 1991, Evans & Sutherland Computer Corporation
  1518. X.SH DIAGNOSTICS
  1519. X.B Mail-bin
  1520. Xwill complain about missing files and perform no action.
  1521. X.SH BUGS
  1522. XNone known.
  1523. END_OF_FILE
  1524. if test 6632 -ne `wc -c <'mail-bin.1'`; then
  1525.     echo shar: \"'mail-bin.1'\" unpacked with wrong size!
  1526. fi
  1527. # end of 'mail-bin.1'
  1528. fi
  1529. echo shar: End of shell archive.
  1530. exit 0
  1531.  
  1532. exit 0 # Just in case...
  1533.