Skip to content

Instantly share code, notes, and snippets.

@gerardo-junior
Last active August 2, 2021 06:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerardo-junior/0876935c91a83c4b87661c649217397c to your computer and use it in GitHub Desktop.
Save gerardo-junior/0876935c91a83c4b87661c649217397c to your computer and use it in GitHub Desktop.
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
Copy link
Author

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

@mexicodespierto
Copy link

Oi Gerardo

Espero que vc esta muito bem.

Muito brigado pelo seu script https://reddit.com/r/termux/comments/ifrudp/fixing_termuxsendsms_commad_after_removing_the/

Esta ótimo y funciona perfeito desde Termux.

Mais agora estou usando seu script adentro do meu python script y nao funciona mais. Nao tira error. Vc sabe como poder melhorar o meu código para poder enviar messages de SMS desde um script de python? Aqui esta meu código. Acho do que um problema com "import subprocess". Muito brigado pela sua ayuda!

https://gist.github.com/mexicodespierto/23bb6286a09110812f19d00319faeaa0

import subprocess
import csv
import time

print("The app is running")
file = open('/storage/emulated/0/DCIM/Python/message.txt','r')
smsmessage = http://file.read()

with open('/storage/emulated/0/DCIM/Python/numbers.txt') as csvfile:
csv_reader = csvfile.readlines()

counter = 0

num = "+525565391232"
http://subprocess.run(["termux-sms-send", "-n", num, smsmessage])
print("message sent to me")
for number in csv_reader:
counter += 1
http://subprocess.run(["termux-sms-send", "-n", number, smsmessage])
print("Sent Message " + smsmessage + " to " + number)
print (counter)
time.sleep(7)
if (counter%10==0):
print (counter)
http://subprocess.run(["termux-sms-send", "-n", num, smsmessage])
time.sleep(7)

print("Message sending complete")

@gerardo-junior
Copy link
Author

@mexicodespierto this script became useless because termux started to support calls and sms again if installed by f-droid. about your script, did you put the script in your PATH? and the subprocess needs a parameter to be able to capture the function's return. in my timezone it's already late, but tomorrow afternoon I'll send you a corrected version of your script.

@mexicodespierto
Copy link

Sorry Gerardo. It's already working fine. Thx!

@mexicodespierto
Copy link

Hi Gerardo

Looks like I can't put a link inside the message. Any idea how we can fix this? This is my message. Without the link I can send it but adding the link the message won't be sent.

Hola amigo, hola amiga

Hoy salieron a la calle cientos de millones de ciudadanos en todas las ciudades en todo el mundo. Te gustaría ver las imágenes y los videos de tanta gente manifestando? Y quieres saber porque están manifestando?

Te invitamos a investigar lo que de verdad está pasando con este covid y la plandemia. Si quieres saber más, conéctate a nuestro grupo de discusión:

https://chat.whatsapp.com/Hos81Upkpeh6rX8XakMG2m

@mexicodespierto
Copy link

mexicodespierto commented Aug 2, 2021

I found out, that all messages with the word "Whatsapp" in it... won't get through. Crazy times. So I changed the whatsapp link to a tiny url link... Now I can send it. Thank you Gerardo. Who would have known... that they are blocking this word. Crazy, crazy... I still can't believe it.

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