home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / base / root.15 / usr / bin / metasend / metasend~
Text File  |  1998-08-19  |  11KB  |  419 lines

  1. #!/bin/sh
  2. # The following was generated from 
  3. # NLS/en/metamail.gen
  4. #
  5. MF_METAMAIL=metamail.cat@mail
  6. #
  7. MS_EXTCOMPOSE=1
  8. EXTCOMPOSE_MSG_WHERE=1
  9. EXTCOMPOSE_MSG_LOCAL=2
  10. EXTCOMPOSE_MSG_AFS=3
  11. EXTCOMPOSE_MSG_ANON=4
  12. EXTCOMPOSE_MSG_LOGIN=5
  13. EXTCOMPOSE_MSG_MAILSRVR=6
  14. EXTCOMPOSE_MSG_NUMBER=7
  15. EXTCOMPOSE_MSG_DOMAIN=8
  16. EXTCOMPOSE_MSG_DIR=9
  17. EXTCOMPOSE_MSG_NAME=10
  18. EXTCOMPOSE_MSG_TRANSFER=11
  19. EXTCOMPOSE_MSG_PATH=12
  20. EXTCOMPOSE_MSG_ADDR=13
  21. EXTCOMPOSE_MSG_ACCESS=14
  22. EXTCOMPOSE_MSG_CONTENT=15
  23. EXTCOMPOSE_MSG_ENCODED=16
  24. EXTCOMPOSE_MSG_NOT=17
  25. EXTCOMPOSE_MSG_BASE64=18
  26. EXTCOMPOSE_MSG_QP=19
  27. EXTCOMPOSE_MSG_UUENCODE=20
  28. EXTCOMPOSE_MSG_DATA=21
  29. EXTCOMPOSE_ERR_USAGE=22
  30. EXTCOMPOSE_ERR_CHOICE=23
  31. EXTCOMPOSE_ERR_EXIST=24
  32. #
  33. MS_GETFILENAME=2
  34. GETFILENAME_MSG_NAME=1
  35. GETFILENAME_ERR_NO_FILE=2
  36. #
  37. MS_METASEND=3
  38. METASEND_MSG_TO=1
  39. METASEND_MSG_SUBJECT=2
  40. METASEND_MSG_CC=3
  41. METASEND_MSG_CONTENT=4
  42. METASEND_MSG_FILE=5
  43. METASEND_MSG_ENC=6
  44. METASEND_MSG_NO=7
  45. METASEND_MSG_BASE64=8
  46. METASEND_MSG_QP=9
  47. METASEND_MSG_UUENCODE=10
  48. METASEND_ERR_S=11
  49. METASEND_ERR_C=12
  50. METASEND_ERR_SUB=13
  51. METASEND_ERR_T=14
  52. METASEND_ERR_E=15
  53. METASEND_ERR_F=16
  54. METASEND_ERR_M=17
  55. METASEND_ERR_OPTION=18
  56. METASEND_ERR_FILE=19
  57. METASEND_ERR_ANSWER=20
  58. METASEND_ERR_BATCH=21
  59. METASEND_ERR_DATAFILE=22
  60. METASEND_ERR_DELIVERY=23
  61. METASEND_ERR_DRAFT=24
  62. #
  63. MS_SHOWAUDIO=4
  64. SHOWAUDIO_MSG_CHOOSE=1
  65. SHOWAUDIO_MSG_SPEAKER=2
  66. SHOWAUDIO_MSG_TELEPHONE=3
  67. SHOWAUDIO_MSG_PREFER=4
  68. SHOWAUDIO_MSG_USE_PHONE=5
  69. SHOWAUDIO_MSG_FUTURE=6
  70. SHOWAUDIO_MSG_USE_SPEAKER=7
  71. SHOWAUDIO_MSG_SENDING=8
  72. SHOWAUDIO_MSG_AIFF=9
  73. SHOWAUDIO_MSG_NEXT=10
  74. SHOWAUDIO_MSG_DEV=11
  75. SHOWAUDIO_MSG_NUMBER=12
  76. SHOWAUDIO_MSG_CALLING=13
  77. SHOWAUDIO_MSG_DONE=14
  78. SHOWAUDIO_MSG_RSH=15
  79. SHOWAUDIO_MSG_CANT_PLAY=16
  80. #
  81. MS_SHOWEXTERNAL=5
  82. SHOWEXTERNAL_MSG_ANON=1
  83. SHOWEXTERNAL_MSG_FTP=2
  84. SHOWEXTERNAL_MSG_SRVR=3
  85. SHOWEXTERNAL_MSG_DATA=4
  86. SHOWEXTERNAL_MSG_SITE=5
  87. SHOWEXTERNAL_MSG_USER=6
  88. SHOWEXTERNAL_MSG_PASSWD=7
  89. SHOWEXTERNAL_MSG_BODY=8
  90. SHOWEXTERNAL_MSG_SU=9
  91. SHOWEXTERNAL_MSG_GETTING=10
  92. SHOWEXTERNAL_MSG_REQUESTED=11
  93. SHOWEXTERNAL_MSG_RM=12
  94. SHOWEXTERNAL_ERR_NAME=13
  95. SHOWEXTERNAL_ERR_USAGE=14
  96. SHOWEXTERNAL_ERR_FTP=15
  97. SHOWEXTERNAL_ERR_FOUND=16
  98. SHOWEXTERNAL_ERR_BODYFILE=17
  99. SHOWEXTERNAL_ERR_MAIL=18
  100. SHOWEXTERNAL_ERR_TYPE=19
  101. SHOWEXTERNAL_ERR_METAMAIL=20
  102. SHOWEXTERNAL_ERR_ENTER=21
  103. #
  104. MS_SHOWNONASCII=6
  105. SHOWNONASCII_MSG_DISPLAY=1
  106. SHOWNONASCII_MSG_XTERM=2
  107. #
  108. MS_SHOWPARTIAL=7
  109. SHOWPARTIAL_MSG_READ=1
  110. SHOWPARTIAL_MSG_WARN=2
  111. SHOWPARTIAL_MSG_SEV=3
  112. SHOWPARTIAL_MSG_TOTAL=4
  113. SHOWPARTIAL_MSG_FULL=5
  114. SHOWPARTIAL_ERR_USAGE=6
  115. SHOWPARTIAL_ERR_TREEROOT=7
  116. SHOWPARTIAL_ERR_ID=8
  117. SHOWPARTIAL_ERR_CP=9
  118. #
  119. MS_SHOWPICTURE=8
  120. SHOWPICTURE_MSG_DISPLAY=1
  121. SHOWPICTURE_MSG_NOTE=2
  122. # Copyright (c) 1998 The Santa Cruz Operation, Inc.. All Rights Reserved. 
  123. #                                                                         
  124. #        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE               
  125. #                   SANTA CRUZ OPERATION INC.                             
  126. #                                                                         
  127. #   The copyright notice above does not evidence any actual or intended   
  128. #   publication of such source code.                                      
  129.  
  130. #
  131. #    ident @(#) metasend.sh 11.2 97/11/03 
  132. #
  133. #############################################################################
  134. #
  135. #    Copyright (c) 1997 The Santa Cruz Operation, Inc.. 
  136. #        All Rights Reserved. 
  137. #
  138. #    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF 
  139. #        THE SANTA CRUZ OPERATION INC.
  140. #    The copyright notice above does not evidence any
  141. #    actual or intended publication of such source code.
  142. #
  143. #############################################################################
  144. #
  145. # Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
  146. # Permission to use, copy, modify, and distribute this material 
  147. # for any purpose and without fee is hereby granted, provided 
  148. # that the above copyright notice and this permission notice 
  149. # appear in all copies, and that the name of Bellcore not be 
  150. # used in advertising or publicity pertaining to this 
  151. # material without the specific, prior written permission 
  152. # of an authorized representative of Bellcore.  BELLCORE 
  153. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 
  154. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS", 
  155. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  156. #
  157. #############################################################################
  158. #
  159. # Conversion from C shell to Bourne shell by Z-Code Software Corp.
  160. # Conversion Copyright (c) 1992 Z-Code Software Corp.
  161. # Permission to use, copy, modify, and distribute this material
  162. # for any purpose and without fee is hereby granted, provided
  163. # that the above copyright notice and this permission notice
  164. # appear in all copies, and that the name of Z-Code Software not
  165. # be used in advertising or publicity pertaining to this
  166. # material without the specific, prior written permission
  167. # of an authorized representative of Z-Code.  Z-CODE SOFTWARE
  168. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
  169. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS",
  170. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  171. #
  172.  
  173. echo_n()
  174. {
  175.     echo "$@\c"
  176. }
  177.  
  178. :
  179.  
  180. if [ -z "$METAMAIL_TMPDIR" ]
  181. then METAMAIL_TMPDIR=/tmp
  182. fi
  183.  
  184. MustDelete=0
  185. batchmode=0
  186. splitsize=100000
  187.  
  188. while test ! -z "$*"
  189. do
  190.     case $1 in
  191.         -S) shift
  192.             if test -z "$*"
  193.             then
  194.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_S \
  195.                 "-S requires a following argument, the SPLIT threshhold\n" "-S"
  196.             exit 1
  197.             fi
  198.             splitsize=$1
  199.             shift ;;
  200.  
  201.         -b) batchmode=1
  202.             shift ;;
  203.  
  204.         -c) shift
  205.             if test -z "$*"
  206.             then
  207.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_C \
  208.                 "-c requires a following argument, the CC address\n" "-c"
  209.             exit 1
  210.             fi
  211.             cc=$1
  212.             shift ;;
  213.  
  214.         -s) shift
  215.             if test -z "$*"
  216.             then
  217.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_SUB \
  218.                 "-s requires a following argument, the SUBJECT\n" "-s"
  219.             exit 1
  220.             fi
  221.             subject=$1
  222.             shift ;;
  223.  
  224.         -t) shift
  225.             if test -z "$*"
  226.             then
  227.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_T \
  228.                 "-t requires a following argument, the TO address\n" "-t"
  229.             exit 1
  230.             fi
  231.             to=$1
  232.             shift ;;
  233.  
  234.         -e) shift
  235.             if test -z "$*"
  236.             then
  237.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_E \
  238.                 "-e requires a following argument, the ENCODING value\n" "-e"
  239.             exit 1
  240.             fi
  241.             encode=$1
  242.             shift ;;
  243.  
  244.         -f) shift
  245.             if test -z "$*"
  246.             then
  247.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_F \
  248.                 "-f requires a following argument, the DATA FILE\n" "-f"
  249.             exit 1
  250.             fi
  251.             datafile=$1
  252.             shift ;;
  253.  
  254.         -m) shift
  255.             if test -z "$*"
  256.             then
  257.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_M \
  258.                 "-m requires a following argument, the MIME CONTENT-TYPE\n" "-m"
  259.             exit 1
  260.             fi
  261.             ctype=$1
  262.             shift ;;
  263.  
  264.         -z) MustDelete=1
  265.             shift ;;
  266.  
  267.         *) dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_OPTION \
  268.             "UNRECOGNIZED METASEND OPTION: $1\n" "$1"
  269.            exit 1 ;;
  270.     esac
  271. done
  272.  
  273. if test $batchmode -eq 0
  274. then
  275.     if test -z "${to:-}"
  276.     then
  277.         dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_TO "To: "
  278.         read to
  279.     fi
  280.     if test -z "${subject:-}"
  281.     then
  282.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_SUBJECT \
  283.             "Subject: "
  284.         read subject
  285.     fi
  286.     if test -z "${cc:-}"
  287.     then
  288.         dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_CC "CC: "
  289.         read cc
  290.     fi
  291.     if test -z "${ctype:-}"
  292.     then
  293.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_CONTENT \
  294.             "Content-type: "
  295.         read ctype
  296.     fi
  297.     if test -z "${datafile:-}"
  298.     then
  299.         looping=1
  300.         while test $looping -eq 1
  301.         do
  302.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_FILE \
  303.                 "Name of file containing $ctype data: " "$ctype"
  304.             read datafile
  305.             if test -r "$datafile"
  306.             then
  307.                 looping=0
  308.             else
  309.                 dspmsg $MF_METAMAIL -s $MS_METASEND \
  310.                     $METASEND_ERR_FILE \
  311.                     "The file $datafile does not exist.\n" \
  312.                     "$datafile"
  313.             fi
  314.         done
  315.     fi
  316.  
  317.     if test -z "${encode:-}"
  318.     then
  319.         looping=1
  320.         while test $looping -eq 1
  321.         do
  322.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_ENC \
  323.                 "Do you want to encode this data for sending through the mail?\n"
  324.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_NO \
  325.                 "  1 -- No, it is already in 7 bit ASCII\n"
  326.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_BASE64 \
  327.                 "  2 -- Yes, encode in base64 (most efficient)\n"
  328.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_QP \
  329.                 "  3 -- Yes, encode in quoted-printable (less efficient, more readable)\n"
  330.             dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_UUENCODE \
  331.                 "  4 -- Yes, encode it using uuencode (not standard, being phased out)\n"
  332.             read encode
  333.             looping=0
  334.             case "$encode" in
  335.                 1) encodingprog=cat
  336.                    encode=7bit ;;
  337.                 2) encodingprog="mimencode -b"
  338.                    encode=base64 ;;
  339.                 3) encodingprog="mimencode -q"
  340.                    encode=quoted-printable ;;
  341.                 4) encodingprog="uuencode $datafile"
  342.                    encode=x-uue ;;
  343.                 *) dspmsg $MF_METAMAIL -s $MS_METASEND \
  344.                     $METASEND_ERR_ANSWER \
  345.                     "Unrecognized answer, please try again.\n"
  346.                    looping=1 ;;
  347.             esac
  348.         done
  349.     fi
  350. else
  351.     if test -z "${to:-}" \
  352.         -o -z "${subject:-}" \
  353.         -o -z "${ctype:-}" \
  354.         -o -z "${datafile:-}"
  355.     then
  356.         dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_BATCH \
  357.             "metasend: in batch mode, -t, -s, -f, and -m are all required\n" \
  358.             "-t" "-s" "-f" "-m"
  359.         exit 1
  360.     fi
  361.  
  362.     if test ! -r "$datafile"
  363.     then
  364.         dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_DATAFILE \
  365.             "metasend: The file $datafile does not exist\n" "$datafile"
  366.         exit 1
  367.     fi
  368.  
  369.     if test -z "${cc:-}"
  370.     then
  371.         cc=''
  372.     fi
  373.  
  374.     if test -z "${encode:-}"
  375.     then
  376.         case "$ctype" in
  377.             text*) encodingprog="mimencode -q"
  378.                    encode=quoted-printable ;;
  379.             *) encodingprog="mimencode -b"
  380.                encode=base64 ;;
  381.         esac
  382.     else
  383.         case "$encode" in
  384.             base64) encodingprog="mimencode -b" ;;
  385.             x-uue) encodingprog="uuencode $datafile" ;;
  386.             *) encodingprog="mimencode -q"
  387.                encode=quoted-printable ;;
  388.         esac
  389.     fi
  390. fi
  391.  
  392. fname=$METAMAIL_TMPDIR/metasend.$$
  393. echo "To: $to" > $fname
  394. echo "Subject: $subject" >> $fname
  395. echo "CC: $cc" >> $fname
  396. echo "MIME-Version: 1.0" >> $fname
  397. echo "Content-type: $ctype" >> $fname
  398. echo "Content-Transfer-Encoding: $encode" >> $fname
  399. echo "" >> $fname
  400. $encodingprog < "$datafile" >> "$fname"
  401. # Ensure last line has trailing carriage return
  402. echo "" >> "$fname"
  403.  
  404. splitmail -s $splitsize -d $fname
  405.  
  406. if test $? -eq 0
  407. then
  408.     rm -f $fname
  409. elif test "$MustDelete" -eq 1
  410. then
  411.     dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_DELIVERY \
  412.         "Mail delivery failed\n"
  413.     rm -f $fname
  414. else
  415.     dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_DRAFT \
  416.         "Mail delivery failed, draft mail is in $fname\n" "$fname"
  417. fi
  418.