--//--Working code--//--
The thing is: Gammu sms inject acctually sends data to mysql database called smsd.
Creating this database: This should be created as specified in wammu sql database. Storing the SQL script for creating tables in MySQL database will able you to import it with phpmyadmin(gui) or any other way to interface mysql.
Run on recieve Add to the end of /etc/gammu-smsdrc --configuration file for gammu
runOnRecieve = /path/to/bash/file
Open the /path/to/bash/file
#!/bin/bash
str=$SMS_1_TEXT //codeword "weather"
tlf=$SMS_1_NUMBER //+47 41412424
tlf=${tlf:3} //remove +47
if test "$tlf" = "41412424"; then
toSend = "[Weather for today in Norway]"
else
toSend = "[you are not part of this group]"
echo "Someone outside the group send to this number" > /home/user/activity.txt
fi
mysql --host=localhost --user=username --password=pw smsd << EOF
INSERT INTO outbox (
DestinationNumber,
TextDecoded,
CreatorID,
RelativeValidity
) VALUES (
'$tlf',
'$toSend',
'Program',
'255'
);
EOF
Start the daemon
$ sudo gammu-smsd
That should be it!
Extra tips:
- Use
$ gammu-detect
to find out where the device is connected. Look forname = Phone on USB serial port HUAWEI_Technology HUAWEI_Mobile
or something similar. Put this info in the configfile. - Be shure to add right permission to the bashfile. Make it readable to user running gammu-smsd.
- Make the bashfile executable using chmod u+x /path/to/bash/file.
- The gammu-smsd-monitor can be used to check how good signal you have. Be shure not to stop running the gammu-smsd when trying to run this.
- You can test the bashfile by running it with dummy tlf and dummytext as input.
$ ./bashfile.sh
.