#!/usr/local/bin/zplay -X/bin/sh
#!/bin/sh
#
# demo for the new dialout zplay option
#
# $1 - phone number to dial
# $2 - filename of the message to be send
#

NAME=`basename $0`

if [ "$1" = "" -o "$2" = "" ]; then
	echo "usage: "$NAME" phonenumber messagefile" >&2
	exit 1
fi

RESULT=`zplay -S -d "$1"`

if [ $RESULT = "1" ]; then
	echo $NAME": error dialing number "$1 >&2
	exit 1
fi

if [ $RESULT = "2" ]; then
	echo $NAME": no answer from "$1 >&2
	exit 2
fi

zplay -S $2

echo $NAME": message "$2" successfully delivered to number "$1
exit 0
