14 March 2014

Send SMS from Bash script

Since Gnokii failed me without any valid reason, I tried to write myself a piece of code to send SMS from the Linux bash command line.
This script is still buggy and has several race condition issues if you usually send more SMS at once.

shift 1

echo -e -n "AT+CMGF=1 \015" > $MODEM
echo -e -n "AT+CMGS=\"$NUMBER\" \015" > $MODEM
echo -e -n "$TEXT \015" | cut -c1-150 | tr -d '\n' > $MODEM
echo -e -n "\032" > $MODEM
echo To: $NUMBER
echo Text: $TEXT
echo SMS sent.

No comments:

Post a comment