| 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 "" |
| 9 | echo " -n number(s) recipient number(s) - separate multiple numbers by commas" |
| 10 | echo "" |
| 11 | exit 0 |
| 12 | } |
| 13 | |
| 14 | RECIPIENTS="" |
| 15 | while getopts :hn: option |
| 16 | do |
| 17 | case "$option" in |
| 18 | h) show_usage;; |
| 19 | n) RECIPIENTS="--esa recipients $OPTARG";; |
| 20 | ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; |
| 21 | esac |
| 22 | done |
| 23 | shift $(($OPTIND-1)) |
| 24 | |
| 25 | if [ -z "$RECIPIENTS" ]; then |
| 26 | echo "$SCRIPTNAME: no recipient number given"; exit 1; |
| 27 | fi |
| 28 | |
| 29 | CMD="@TERMUX_API@ SmsSend $RECIPIENTS" |
| 30 | if [ $# = 0 ]; then |
| 31 | $CMD |
| 32 | else |
| 33 | echo $@ | $CMD |
| 34 | fi |