diff options
-rwxr-xr-x | localsendgroupsms | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/localsendgroupsms b/localsendgroupsms new file mode 100755 index 0000000..81e2bee --- /dev/null +++ b/localsendgroupsms @@ -0,0 +1,40 @@ +#!/bin/sh + +set -e + +simpleword() { + echo "$1" | tr '[A-Z]' '[a-z]' | egrep '^[a-z][a-z0-9-]+$' || exit 1 +} + +uridecode() { + echo "$1" | perl -e 'use URI::Escape; print lc(uri_unescape(<STDIN>));' +} + +urlencode() { + echo "$1" | perl -e 'use URI::URL; print URI::URL->new(<STDIN>)."\n";' +} + +phone=`uridecode "$1" | sed -e 's/\+/ /g'`; shift +set -- `uridecode "$@" | sed -e 's/\+/ /g'` +app=`simpleword "$1"`; shift + +case "$app" in + wadmin|wall) + # coolsms dislikes leading + in phone number + SMS_PHONE=`echo "$SMS_PHONE" | sed 's/^%2b//i'` + origin="$1"; shift + i= + for p in $phone; do + case $p in + $origin) + ;; + *) + /usr/local/sbin/localsendsms "$p" "$@" + i=$((i+1)) + ;; + esac + done + /usr/local/sbin/localsendsms "$origin" "Message \"$1 $2...\" sent to $i recipients." + ;; + *) +esac |