1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
#! /usr/local/bin/vm shell
#
# This script calls the given phone number and plays a message.
#
# $1 - phone number to call
# $2 - filename of the message to play (must be a .rmd file, that
# can be played on the modem used for dialout)
#
# $Id: message.sh,v 1.5 1999/12/04 15:07:34 marcs Exp $
#
#
# Define the function to receive an answer from the voice library
#
function receive
{
read -r INPUT <&$VOICE_INPUT;
echo "$INPUT";
}
#
# Define the function to send a command to the voice library
#
function send
{
echo $1 >&$VOICE_OUTPUT;
kill -PIPE $VOICE_PID
}
#
# Check command line options
#
if [ $# -ne 2 ]; then
echo "usage: $0 <phone_number> <filename>" >&2
exit 99
fi
#
# Let's see if the voice library is talking to us
#
ANSWER=`receive`
if [ "$ANSWER" != "HELLO SHELL" ]; then
kill -KILL $$
fi
send "HELLO VOICE PROGRAM"
ANSWER=`receive`
if [ "$ANSWER" != "READY" ]; then
kill -KILL $$
fi
#
# Enable events
#
send "ENABLE EVENTS"
ANSWER=`receive`
if [ "$ANSWER" != "READY" ]; then
kill -KILL $$
fi
#
# Start dialout
#
send "DIAL $1"
ANSWER=`receive`
if [ "$ANSWER" != "DIALING" ]; then
kill -KILL $$
fi
ANSWER=`receive`
if [ "$ANSWER" != "READY" ]; then
echo "ERROR: $ANSWER, aborting"
exit 99
fi
#
# Disable events
#
send "DISABLE EVENTS"
ANSWER=`receive`
if [ "$ANSWER" != "READY" ]; then
kill -KILL $$
fi
#
# Now play the message file
#
send "PLAY $2"
ANSWER=`receive`
if [ "$ANSWER" != "PLAYING" ]; then
kill -KILL $$
fi
ANSWER=`receive`
if [ "$ANSWER" != "READY" ]; then
kill -KILL $$
fi
#
# Let's say goodbye
#
send "GOODBYE"
ANSWER=`receive`
if [ "$ANSWER" != "GOODBYE SHELL" ]; then
kill -KILL $$
fi
echo "OK: message sent"
exit 0
|