chiark / gitweb /
wip
[post-pizza-notify.git] / notify
diff --git a/notify b/notify
new file mode 100644 (file)
index 0000000..597877e
--- /dev/null
+++ b/notify
@@ -0,0 +1,33 @@
+#!/bin/bash
+set -e
+
+case "$#.$1" in
+2.[^-]*)       ;;
+*)             echo >&2 "usage: ./notify recipientsfile 'message'"; exit 1;;
+esac
+
+rcpts="$1"
+msg="$2"
+
+exec <"$rcpts"
+line=0
+while read method data; do
+       line=$(( $line+1 ))
+       case "$method" in
+       #*|'')  continue ;;
+       [^a-z]*) echo >&2 "huh ? $rcpts:$line: $method"; continue ;;
+       log=log-$method-$line.txt
+       exec >$log
+       set +e
+       printf >&2 "sms"
+       ./"via-$method" $data 2>&1
+       rc=$?
+       set -e
+       if [ $rc != 0 ]; then
+               printf >&2 "-FAIL:%s\n" $log
+       else
+               printf >&2 " "
+       fi
+done
+exec >&2
+echo >&2