Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fixed termux-send-sms script after removing the sms feature
#!/data/data/com.termux/files/usr/bin/sh
set -e -u
# Frist install https://f-droid.org/en/packages/com.android.shellms/ and give sms permission manually
SCRIPTNAME=termux-sms-send
show_usage () {
echo "Usage: $SCRIPTNAME -n number[,number2,number3,...] [text]"
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."
echo " -n number(s) recipient number(s) - separate multiple numbers by commas"
exit 0
}
RECIPIENTS=""
while getopts :hn: option
do
case "$option" in
h) show_usage;;
n) RECIPIENTS="$OPTARG";;
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
esac
done
shift $((OPTIND-1))
if [ -z "$RECIPIENTS" ]; then
echo "$SCRIPTNAME: no recipient number given"; exit 1;
fi
if [ $# = 0 ]; then
echo "$SCRIPTNAME: no msg given"
else
echo $RECIPIENTS | tr ',' '\n' | while read number;do
/data/data/com.termux/files/usr/bin/am startservice --user 0 -n com.android.shellms/.sendSMS -e contact "$number" -e msg "$*" > /dev/null
done
fi
@gerardo-junior

This comment has been minimized.

Copy link
Owner Author

@gerardo-junior gerardo-junior commented Aug 24, 2020

for json return problem *work in progress... try2codesecure/ShellMS#23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment