Last active
December 14, 2015 11:28
-
-
Save kolobus/5079057 to your computer and use it in GitHub Desktop.
Replacement for gnokii SMS daemon. Based on http://xgu.ru/wiki/Gnokii but a bit tricky.
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
<?php | |
if ($_REQUEST["sender"] == "+7921*******" AND $_REQUEST["pass"] == "****") { | |
// You're free to do any actions - post to twitter, send another SMS or just write to file | |
// As I do for displaying this on my homepage | |
$fp = fopen("/home/kolo/****/****.txt","w"); | |
fwrite($fp, stripslashes($_REQUEST["text"])); | |
fclose($fp); | |
mail("kolo@****", "SMS Alarm @ +7926****", var_export($_REQUEST, true)); // Good for debugging | |
} | |
?> |
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/sh | |
# Before asking why I use wget, but not just writing to file | |
# think of this running on different hosts | |
smsgate() | |
{ | |
sender="`gnokii --getsms SM 1 2> /dev/null | grep Sender | awk '{print $2}' 2> /dev/null`"; | |
[ -z "$sender" ] || { | |
result="$(gnokii --getsms SM 1 2> /dev/null | sed '1,/^Text:/ d' 2> /dev/null)"; | |
echo $sender:$result >> /home/kolo/sms.log; | |
wget -O -q /dev/null "http://example.org/stuff/getsms.php?pass=****&sender=$sender&text=$result" > /dev/null 2> /dev/null | |
gnokii --deletesms SM 1 >/dev/null 2> /dev/null | |
} | |
} | |
while true | |
do | |
smsgate | |
sleep 10 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment