| 1 | #!/bin/sh |
| 2 | set -e -u |
| 3 | |
| 4 | SCRIPTNAME=termux-sms-send |
| 5 | show_usage () { |
| 6 | echo "Usage: $SCRIPTNAME -n number[,number2,number3,...] [text]" |
| 7 | echo "Send a SMS message to the specified recipient number(s). The text to send is either supplied as arguments or read from stdin if no arguments are given." |
| 8 | echo " -n number(s) recipient number(s) - separate multiple numbers by commas" |
| 9 | exit 0 |
| 10 | } |
| 11 | |
| 12 | RECIPIENTS="" |
| 13 | while getopts :hn: option |
| 14 | do |
| 15 | case "$option" in |
| 16 | h) show_usage;; |
| 17 | n) RECIPIENTS="--esa recipients $OPTARG";; |
| 18 | ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; |
| 19 | esac |
| 20 | done |
| 21 | shift $(($OPTIND-1)) |
| 22 | |
| 23 | if [ -z "$RECIPIENTS" ]; then |
| 24 | echo "$SCRIPTNAME: no recipient number given"; exit 1; |
| 25 | fi |
| 26 | |
| 27 | CMD="@TERMUX_API@ SmsSend $RECIPIENTS" |
| 28 | if [ $# = 0 ]; then |
| 29 | $CMD |
| 30 | else |
| 31 | echo $@ | $CMD |
| 32 | fi |