Example script: MailPkg.sh


   1: #!/bin/sh
   2: #
   3: # Copyright 1995, by Hewlett-Packard Company
   4: #
   5: # The code in this file is from the book "Shell Programming
   6: # Examples" by Bruce Blinn, published by Prentice Hall.
   7: # This file may be copied free of charge for personal,
   8: # non-commercial use provided that this notice appears in
   9: # all copies of the file.  There is no warranty, either
  10: # expressed or implied, supplied with this code.
  11: #
  12: # SYNOPSIS
  13: #   MailPkg address package file ...
  14: #
  15: ADDRESS=$1
  16: PACKAGE=$2
  17: shift 2
  18: 
  19: tar -cf /tmp/package.$$ $*
  20: 
  21: mkdir /tmp/split.$$
  22: cd /tmp/split.$$
  23: compress  -cf /tmp/package.$$      |
  24:      uuencode $PACKAGE.tar.Z  |
  25:      split -1000
  26: 
  27: PARTNUM=1
  28: MESSAGE=/tmp/message.$$
  29: set x*
  30: TOTAL=$#
  31: while [ $# -gt 0 ]
  32: do
  33:     cat <<_EOF >$MESSAGE
  34:     This is part $PARTNUM of $TOTAL of a compressed and
  35:     uuencoded tar file.
  36:     -   File: $PACKAGE.tar.Z
  37:     -   Part: $PARTNUM
  38:     ----- Cut Here -----
  39: _EOF
  40: 
  41:     cat $1                      >>$MESSAGE
  42:     echo "----- Cut Here -----" >>$MESSAGE
  43: 
  44:     mail $ADDRESS <$MESSAGE
  45: 
  46:     shift
  47:     PARTNUM=`expr $PARTNUM + 1`
  48: done
  49: 
  50: cd $OLDPWD
  51: rm /tmp/package.$$
  52: rm /tmp/message.$$
  53: rm -rf /tmp/split.$$



  last modified 22/03/2012 Introduction Table of Contents
(frame/no frame)
Printable
(single file)
© Dartmouth College