短信回复脚本gammu

时间:2016-06-17 18:53:26

标签: bash shell raspberry-pi sms gammu

我在第一篇求助的帖子。

以下脚本希望:

收到短信,如果有50%的人回复并发布活动

然后验证针对1 -10范围内的答复,以及是否在范围内和来自相同数字的答复还原消息,否则还原为不同的答案。

当它将第二条消息恢复为该号码时,会向所有其他消息发送一般消息。

您怎么看?

#!/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"

1 个答案:

答案 0 :(得分:1)

使用SMSD时不能直接使用gammu,使用gammu-smsd-inject通过SMSD发送消息。

如果您在调试脚本时遇到麻烦,请参阅http://wammu.eu/docs/manual/faq/smsd.html#the-runonreceive-script-fails-how-to-fix-that