Last active
January 1, 2016 18:09
-
-
Save frafra/8181782 to your computer and use it in GitHub Desktop.
Send SMS using USB dongle or smartphone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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