home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / metamail / contrib / sgi / audiosend < prev    next >
Encoding:
Text File  |  1992-05-21  |  2.0 KB  |  124 lines

  1. #!/bin/sh
  2.  
  3. PATH=/usr/local/MetaMail:/bin:/usr/bin:/usr/ucb:/usr/sbin
  4. export PATH
  5.  
  6. fname=/tmp/audio-out.$$
  7. fnameraw=/tmp/audio-raw.$$
  8.  
  9. trap 'kill -9 $recordpid; rm -f /tmp/audio.$$ $fname $fnameraw; exit' 2
  10.  
  11. hosttype=`uname`
  12. case $hosttype in
  13. IRIX|SunOS|News)
  14.     ;;
  15. *)
  16.     cat <<\+
  17. There is currently no way in which you can record audio on this type of
  18. workstation.  If you log into an appropriate machine (currently a
  19. SPARCstation, Sony News workstation, or Silicon Graphics Personal Iris or
  20. Iris Indigo), you should be able to record a message.
  21. +
  22.     exit 1
  23.     ;;
  24. esac
  25.  
  26. case `echo -n x` in
  27. -n*)    n= c='\c';;
  28. *)    n=-n c=;;
  29. esac
  30.  
  31. echo $n "To: $c"
  32. read to
  33. echo $n "Subject: $c"
  34. read subject
  35. echo $n "Cc: $c"
  36. read cc
  37.  
  38. while :
  39. do
  40.     echo $n "Press RETURN when you are ready to start recording: $c"
  41.     read answer
  42.  
  43.     cat > $fname << +
  44. To: $to
  45. Subject: $subject
  46. Cc: $cc
  47. MIME-Version: 1.0
  48. Content-Type: audio/basic
  49. Content-Transfer-Encoding: base64
  50.  
  51. +
  52.  
  53.     if [ "${RECORD_AUDIO+defined}" = defined ]
  54.     then
  55.         $RECORD_AUDIO > $fnameraw &
  56.     else
  57.         case $hosttype in
  58.         IRIX)
  59.             recordaiff -n 1 -s 16 -r 8000 /tmp/audio.$$ &
  60.             ;;
  61.         SunOS)
  62.             cat /dev/audio > $fnameraw &
  63.             ;;
  64.         News)    # XXX Is this Sony News?
  65.             cat /dev/sb0 > $fnameraw &
  66.             ;;
  67.         esac
  68.     fi
  69.  
  70.     recordpid=$!
  71.  
  72.     echo $n "Press RETURN when you are done recording: $c"
  73.     read answer
  74.  
  75.     echo "One moment please..."
  76.     sleep 1
  77.     echo "Killing recording job..."
  78.     kill -2 $recordpid
  79.     wait
  80.     if [ $hosttype = IRIX ]
  81.     then
  82.         sfconvert /tmp/audio.$$ $fnameraw -o mulaw >/dev/null
  83.         rm -f /tmp/audio.$$
  84.     fi
  85.     mmencode -b < $fnameraw >> $fname
  86.     rm $fnameraw
  87.  
  88.     while :
  89.     do
  90.         cat << \+
  91.  
  92. What do you want to do?
  93.  
  94. 1 -- Send mail
  95. 2 -- Listen to recorded message
  96. 3 -- Replace with a new recording
  97. 4 -- Quit
  98. +
  99.  
  100.         read answer
  101.         case $answer in
  102.         1)
  103.             echo $n "Sending mail, please wait...  $c"
  104.             if /usr/lib/sendmail $to $cc < $fname
  105.             then
  106.                 echo "Done."
  107.                 rm $fname
  108.                 exit 0
  109.             fi
  110.             echo "Mail delivery failed, draft mail is in $fname"
  111.             ;;
  112.         2)
  113.             metamail -d $fname
  114.             ;;
  115.         3)
  116.             break
  117.             ;;
  118.         4)
  119.             exit
  120.             ;;
  121.         esac
  122.     done
  123. done
  124.