My very 1st post to ask for help.
The below script wishes to do:
Receive an SMS that if it has 50% to reply and post an event
Then verify the reply against the a range 1 -10 and if within range and from the same number to revert with message or else to revert with different one.
When it reverts with 2nd message to the number revert with a general message to all others.
What do you think?
#!/bin/sh
from=$SMS_1_NUMBER
message=$SMS_1_TEXT
gammu-smsd[939]: Process failed with exit status 111
if test "$message" = "50%"; then
reply="BRAVO DWSTE TO NOUMERO TRAPEZIOU!"
delay 1
curl "http://10.18.214.12:9999/sendLocalEvent?eventName=event1"
if test [ "$message" -ge 1 -a "$message" -le 10 ] && [ "$from" = "$from" ] ; then
reply="-50% DIKO SAS"
delay 1
curl "http://10.18.214.12:9999/sendLocalEvent?eventName=event2&eventParam=e[ "$message" ]"
else
if [ "$from" = "$from" ]; then
reply="TO NOUMERO TOY TRAPEZIOU EINAI LATHOS"
else
reply="O NHKHTHS VRETHIKE EYXARISTOYME"
fi
echo "$reply" | sudo gammu sendsms TEXT "$from"
sendto="694"
message=$SMS_1_TEXT
from=$SMS_1_NUMBER
echo "$from\n$message" | sudo gammu sendsms TEXT "$sendto"
fi
echo "$reply" | sudo gammu sendsms TEXT "$from"
elif test "$message" = "Ping"; then
reply="Pong!"
else
reply="PARAKALW PROSPATHISTE XANA"
fi
echo "$reply" | sudo gammu sendsms TEXT "$from"
You can not use gammu directly when using SMSD, send message through SMSD by using gammu-smsd-inject.
If you have troubles debugging the script see http://wammu.eu/docs/manual/faq/smsd.html#the-runonreceive-script-fails-how-to-fix-that