home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / rn_4_3_blars.lzh / Rnmail.SH < prev    next >
Text File  |  1990-08-22  |  6KB  |  323 lines

  1. case $CONFIG in
  2.     '') . config.sh ;;
  3. esac
  4. echo "Extracting Rnmail (with variable substitutions)"
  5. $spitshell >Rnmail <<!GROK!THIS!
  6. $startsh
  7. # $Header: Rnmail.SH,v 4.3.2.1 89/11/06 00:30:54 sob Locked $
  8. # $Log:    Rnmail.SH,v $
  9. # Revision 4.3.2.1  89/11/06  00:30:54  sob
  10. # Added RRN support from NNTP 1.5
  11. # Revision 4.3.1.4  85/08/01  14:23:05  lwall
  12. # Added MAILRECORD.  Temp file is no longer in /tmp.  'e editor' added.
  13. # Revision 4.3.1.3  85/05/20  16:25:17  lwall
  14. # Shouldn't ask editor if EDITOR or VISUAL defined.
  15. # Revision 4.3.1.2  85/05/17  10:36:19  lwall
  16. # Added "-- " before .signature.
  17. # Revision 4.3.1.1  85/05/10  11:30:38  lwall
  18. # Branch for patches.
  19. # Revision 4.3  85/05/01  11:34:18  lwall
  20. # Baseline for release with 4.3bsd.
  21. #
  22. # syntax: Rnmail -h headerfile [oldart]        or
  23. #         Rnmail destination-list         or just
  24. #         Rnmail
  25.  
  26. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  27.  
  28. # System dependencies
  29.  
  30. mailer="${mailer-/bin/mail}"
  31. # if you change this to something that does signatures, take out signature code
  32.  
  33. # your site name
  34. case $portable in
  35. define)
  36.     sitename=\`$hostcmd\`
  37.     case \$sitename in
  38.         *.*)
  39.             ;;
  40.         *)
  41.             sitename=\${sitename}.$domain
  42.             ;;
  43.     esac
  44.     ;;
  45. undef) sitename="$sitename" ;;
  46. esac
  47. # your organization name
  48. orgname="$orgname"
  49. # what pager you use--if you have kernal paging use cat
  50. pager="\${PAGER-$pager}"
  51. # how you derive full names, bsd, usg, or other
  52. nametype="$nametype"
  53. # default editor
  54. defeditor="$defeditor"
  55. # how not to do a newline with echo
  56. n="$n"
  57. c="$c"
  58.  
  59. test=${test-test}
  60. sed=${sed-sed}
  61. echo=${echo-echo}
  62. cat=${cat-cat}
  63. grep=${grep-grep}
  64. rm=${rm-rm}
  65.  
  66. !GROK!THIS!
  67. $spitshell >>Rnmail <<'!NO!SUBS!'
  68. dotdir=${DOTDIR-${HOME-$LOGDIR}}
  69. tmpart=$dotdir/.letter
  70.  
  71. headerfile=""
  72. case $# in
  73. 0) ;;
  74. *)  case $1 in
  75.     -h)
  76.     headerfile="$2"
  77.     case $# in
  78.     3) oldart=$3 ;;
  79.     esac
  80.     ;;
  81.     esac
  82.     ;;
  83. esac
  84.  
  85. case $headerfile in
  86. '')
  87.     case $# in
  88.     0)
  89.     to=h
  90.     while $test "$to" = h ; do
  91.         $echo ""
  92.         $echo $n "To: $c"
  93.         read to
  94.         case $to in
  95.         h)
  96.         $cat <<'EOH'
  97.  
  98. Type the net address of those people that you wish the message sent to.
  99. Additional recipients may be added on the Cc: line when you edit.
  100.  
  101. Separate multiple addresses with spaces.
  102.  
  103. EOH
  104.         ;;
  105.         esac
  106.     done
  107.     ;;
  108.     *)
  109.     to="$*"
  110.     ;;
  111.     esac
  112.     to=`$echo "$to" | $sed 's/  */ /g'`
  113.  
  114.     title=h
  115.     while $test "$title" = h ; do
  116.     $echo ""
  117.     $echo $n "Title/Subject: $c"
  118.     read title
  119.     case $title in
  120.     h)
  121.         $cat <<'EOH'
  122.  
  123. Type the title for your message.  
  124. EOH
  125.         ;;
  126.     esac
  127.     done
  128.  
  129. # now build a file with a header for them to edit
  130.     
  131.     orgname=${ORGANIZATION-$orgname}
  132.     case $orgname in
  133.     /*) orgname=`$cat $orgname` ;;
  134.     esac
  135.  
  136.     $cat > $tmpart <<EOHeader
  137. To: $to
  138. Subject: $title
  139. Organization: $orgname
  140. Cc:
  141. Bcc:
  142.  
  143. EOHeader
  144.  
  145.     ;;
  146. *)
  147.     $cat < $headerfile  > $tmpart
  148.     ;;
  149. esac
  150.  
  151.  
  152. file=h
  153. while $test "$file" = h ; do
  154.     $echo ""
  155.     $echo $n "Prepared file to include [none]: $c"
  156.     read file
  157.     case $file in
  158.     h)
  159.     $cat <<'EOH'
  160.  
  161. If you have already produced the body of your message, type the filename
  162. for it here.  If you just want to proceed directly to the editor, type a
  163. RETURN.  In any event, you will be allowed to edit as many times as you
  164. want before you send off the message.
  165. EOH
  166.     ;;
  167.     '')
  168.     $echo "" >> $tmpart
  169.     state=edit
  170.     ;;
  171.     *)
  172.     $cat $file >>$tmpart
  173.     state=ask
  174.     ;;
  175.     esac
  176. done
  177.  
  178. $echo ""
  179.  
  180. while true ; do
  181.     case $state in
  182.     edit)
  183.     rescue="sleep 1; $cat $tmpart >>${HOME-$LOGDIR}/dead.letter ; $echo Message appended to ${HOME-$LOGDIR}/dead.letter ; exit"
  184.     trap "$rescue" 1
  185.     trap : 2
  186.     case "${VISUAL-${EDITOR-}}" in
  187.     '')
  188.         tmp=h
  189.         ;;
  190.     *)
  191.         tmp=''
  192.         ;;
  193.     esac
  194.     while $test "$tmp" = h ; do
  195.         $echo $n "Editor [${VISUAL-${EDITOR-$defeditor}}]: $c"
  196.         read tmp
  197.         case $tmp in
  198.         h)
  199.         $cat <<'EOH'
  200.  
  201. Type a return to get the default editor, or type the name of the editor you
  202. prefer.  The default editor depends on the VISUAL and EDITOR environment
  203. variables.
  204.  
  205. EOH
  206.         ;;
  207.         '')
  208.         ;;
  209.         *)
  210.         VISUAL=$tmp
  211.         export VISUAL
  212.         ;;
  213.         esac
  214.     done
  215.     ${VISUAL-${EDITOR-$defeditor}} $tmpart $oldart
  216.     trap "$rescue" 2
  217.     state=ask
  218.     ;;
  219.     
  220.     ask)
  221.     $echo ""
  222.     $echo $n "Send, abort, edit, or list? $c"
  223.     read ans
  224.     
  225.     case $ans in
  226.     a*)
  227.         state=rescue
  228.         ;;
  229.     e*)
  230.         set $ans
  231.         case $# in
  232.         2)  VISUAL="$2" ;;
  233.         esac
  234.         state=edit
  235.         ;;
  236.     l*)
  237.         $pager $tmpart
  238.         state=ask
  239.         ;;
  240.     s*)
  241.         state=send
  242.         ;;
  243.     h*)
  244.         $cat <<'EOH'
  245.  
  246. Type s to send the message, a to abort and append the message to dead.letter,
  247. e to edit the message again, or l to list the message.
  248.  
  249. To invoke an alternate editor, type 'e editor'.
  250. EOH
  251.     esac
  252.     ;;
  253.     
  254.     send)
  255.     if $test -f $dotdir/.signature; then
  256.         echo $n "Append .signature file? [y] $c"
  257.         read ans
  258.         case $ans in
  259.         ''|y*)
  260.         echo "-- " >> $tmpart
  261.         cat $dotdir/.signature >> $tmpart
  262.         ;;
  263.         esac
  264.     fi
  265.     case $mailer in
  266.     *sendmail)
  267.         $mailer -t <$tmpart
  268.         ;;
  269. # but recmail does not know about Bcc, alas
  270.     *recmail)
  271.         $mailer <$tmpart
  272.         ;;
  273.     *)
  274.         set X `$sed <$tmpart -n -e '/^To:/{' -e 's/To: *//p' -e q -e '}'`
  275.         shift
  276.         set X "$@" `$sed <$tmpart -n -e '/^Cc:/{' -e 's/Cc: *//p' -e q -e '}'`
  277.         shift
  278.         set X "$@" `$sed <$tmpart -n -e '/^Bcc:/{' -e 's/Bcc: *//p' -e q -e '}'`
  279.         shift
  280.         $grep -v "^Bcc:"  <$tmpart | $mailer "$@"
  281.         ;;
  282.     esac
  283.     case $? in
  284.     0)
  285.         state=cleanup
  286.         ;;
  287.     *)
  288.         state=rescue
  289.         ;;
  290.     esac
  291.     ;;
  292.     rescue)
  293.     $cat $tmpart >> ${HOME-$LOGDIR}/dead.letter
  294.     $echo "Message appended to ${HOME-$LOGDIR}/dead.letter"
  295.     $echo "A copy may be temporarily found in $tmpart"
  296.     exit
  297.     ;;
  298.     cleanup)
  299.     case "${MAILRECORD-none}" in
  300.     none)
  301.         ;;
  302.     *)  if $cat $tmpart >> $MAILRECORD; then
  303.         $echo "Article appended to $MAILRECORD"
  304.         else
  305.         $echo "Cannot append to $MAILRECORD"
  306.         fi
  307.         ;;
  308.     esac
  309.     exit
  310.     ;;
  311.     esac
  312. done
  313. !NO!SUBS!
  314. $eunicefix Rnmail
  315. chmod 755 Rnmail
  316.