Commit | Line | Data |
---|---|---|
59f0d218 FF |
1 | #!/bin/sh |
2 | set -e -u | |
3 | ||
0ec2b704 FF |
4 | SCRIPTNAME=termux-sms-send |
5 | show_usage () { | |
6 | echo "Usage: $SCRIPTNAME [-t <text>] <recipient-number>" | |
7 | echo "Send a SMS." | |
8 | echo "" | |
8d6e165f | 9 | echo " -t <text> text to send (optional - else from stdin)" |
0ec2b704 FF |
10 | echo "" |
11 | echo "If no text is specified with the -t option the text to send is read from stdin." | |
12 | exit 0 | |
13 | } | |
14 | ||
15 | TEXT_TO_SEND="" | |
16 | while getopts :ht: option | |
17 | do | |
18 | case "$option" in | |
19 | h) show_usage;; | |
20 | t) TEXT_TO_SEND="$OPTARG";; | |
21 | ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; | |
22 | esac | |
23 | done | |
24 | shift $(($OPTIND-1)) | |
25 | ||
26 | if [ $# = 0 ]; then echo "$SCRIPTNAME: too few arguments"; exit 1; fi | |
27 | if [ $# -gt 1 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi | |
28 | ||
29 | CMD="@TERMUX_API@ SmsSend --es recipient $1" | |
30 | if [ -z "$TEXT_TO_SEND" ]; then | |
31 | $CMD | |
32 | else | |
33 | echo $TEXT_TO_SEND | $CMD | |
59f0d218 FF |
34 | fi |
35 |