Skip to content

Instantly share code, notes, and snippets.

@frafra
Last active January 1, 2016 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frafra/8181782 to your computer and use it in GitHub Desktop.
Save frafra/8181782 to your computer and use it in GitHub Desktop.
Send SMS using USB dongle or smartphone
#!/bin/bash
# sms-from-bash.sh
# Description: Send SMS using USB dongle or smartphone
# Author: FraFra (Francesco Frassinelli - frafra.eu)
# License: GPLv3
MODEM=/dev/ttyACM0
T=3
if [ ! -w $MODEM ]
then
echo "$MODEM not writable"
echo -n "You could add \""$(whoami)"\" to group \"dialout\" using:"
echo " # gpasswd -a $(whoami) dialout"
exit 1
fi
cat $MODEM &
pid=$!
function send {
chat TIMEOUT $T "" "$1" "$2" > $MODEM < $MODEM
}
send "ATZ" "OK"
send "AT+CMGF=1" "OK"
send "AT+CMGS=\"$1\"" "OK"
send "$2" "OK"
send "^Z" "\n"
echo
kill $!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment