home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / metamail / bin / audiosend < prev    next >
Encoding:
Text File  |  1993-05-10  |  2.7 KB  |  108 lines

  1. #!/bin/csh -f
  2. # Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
  3. # Permission to use, copy, modify, and distribute this material 
  4. # for any purpose and without fee is hereby granted, provided 
  5. # that the above copyright notice and this permission notice 
  6. # appear in all copies, and that the name of Bellcore not be 
  7. # used in advertising or publicity pertaining to this 
  8. # material without the specific, prior written permission 
  9. # of an authorized representative of Bellcore.  BELLCORE 
  10. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 
  11. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS", 
  12. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  13. #
  14.  
  15. if (! $?METAMAIL_TMPDIR) then
  16.     set METAMAIL_TMPDIR=/tmp
  17. endif
  18.  
  19. # This is to make metamail/showaudio do playback on the speaker, not the phone.
  20. setenv AUDIOSPEAKERFORCE 1 
  21.  
  22. if (-d /usr/sony) then
  23.     set dev=/dev/sb0
  24. else
  25.     set dev=/dev/audio
  26. endif
  27.  
  28. if ( $#argv == 1 ) then
  29.     set to = $1
  30. else
  31.     echo -n "To: "
  32.     set to = $<
  33. endif
  34. echo -n "Subject: "
  35. set subject = $<
  36. echo -n "CC: "
  37. set cc = $<
  38.  
  39. record:
  40. echo -n "Press RETURN when you are ready to start recording: "
  41. set foo = $<
  42.  
  43. set fname = ${METAMAIL_TMPDIR}/audio-out.$$
  44. set fnameraw = ${METAMAIL_TMPDIR}/audio-raw.$$
  45.  
  46. echo "To: " "$to" > $fname
  47. echo "Subject: " "$subject" >> $fname
  48. echo "CC: " "$cc" >> $fname
  49. echo "MIME-Version: 1.0" >> $fname
  50. echo "Content-Type: audio/basic" >> $fname
  51. echo "Content-Transfer-Encoding: base64" >> $fname
  52. echo  "" >> $fname
  53. # THIS IS UNBELIEVABLY GRUBBY
  54. onintr cleanup
  55. if (! $?RECORD_AUDIO) then
  56.     (/bin/cat < $dev > $fnameraw) &
  57. else
  58.     ($RECORD_AUDIO > $fnameraw) &
  59. endif
  60. jobs -l > ${METAMAIL_TMPDIR}/AUDCAT.$$
  61. set foo=`/bin/cat ${METAMAIL_TMPDIR}/AUDCAT.$$`
  62. /bin/rm ${METAMAIL_TMPDIR}/AUDCAT.$$
  63. set PID=$foo[2]
  64. echo -n "press RETURN when you are done recording: "
  65. set foo=$<
  66. echo One moment please...
  67. /bin/sleep 1
  68. echo -n Killing recording job...
  69. /bin/kill -9 $PID >& /dev/null
  70. mimencode -b < $fnameraw >> $fname
  71. /bin/rm $fnameraw
  72. echo "" >> $fname
  73.  
  74. whatnext:
  75. echo ""
  76. echo "What do you want to do?"
  77. echo ""
  78. echo "1 -- Send mail"
  79. echo "2 -- Listen to recorded message"
  80. echo "3 -- Replace with a new recording"
  81. echo "4 -- Quit"
  82. set which = $<
  83.     switch ("$which")
  84.         case 1:
  85.           echo -n "Sending mail, please wait...  "
  86.           /usr/lib/sendmail $to  $cc < $fname
  87.           if (! $status) then
  88.             echo "Done."
  89.             rm $fname
  90.             exit
  91.           else
  92.             echo Mail delivery failed, draft mail is in $fname
  93.           endif
  94.           breaksw
  95.         case 2:
  96.           metamail -d $fname
  97.           breaksw
  98.         case 3:
  99.           goto record
  100.         case 4:
  101.           exit
  102.     endsw
  103. goto whatnext
  104. exit 0
  105. cleanup:
  106. kill -9 $PID >& /dev/null
  107.