#!/bin/sh 
# sendsms
# sms_client wrapper
# By Andrew Dalgleish <andrewd@axonet.com.au>

if test ! "$BBTMP"                      # GET DEFINITIONS IF NEEDED
then
	. $BBHOME/etc/bbdef.sh          # INCLUDE STANDARD DEFINITIONS
fi

SMS_CLIENT=/bin/sms_client

if [ ! -x "$SMS_CLIENT" ]
then
	echo "SMS_CLIENT not set properly in $BBHOME/bin/sendsms"
	exit 1
fi

#-----------------------------------------------------------------------------
# Send a message using sms_client, multiple attempts
#-----------------------------------------------------------------------------
#

    I=1
    while test $I -le 10
    do
	# echo "page; trying to send, attempt: $I"
	I=`$EXPR $I + 1`
	# Make sure the message is wrapped in quotes, else sms_client will send it one word per SMS
	$SMS_CLIENT "$1" "$2" > /dev/null
	if test "$?" = "0" 
	then
	    I=999 # make sure loop ends...
	fi
    done
