2013-10-03 38 views
0

我在linux上有一個華爲E220 HSDPA調制解調器xubuntu 我想收到短信並自動回覆發件人。 我使用gammu和Gammu-smsd來做到這一點。在huawei調制解調器,gammu-smsd上收到並回復短信:進程失敗,退出狀態2

要自動發送短信,我將runOnRecieve =/path/to/bash /文件添加到/ etc/gammu-smsdrc配置文件中。

下面是腳本:

#!/bin/bash 
str=$SMS_1_TEXT //string containing text from sender 
tlf=$SMS_1_NUMBER //containing number from sender 
tlf=${tlf:3} 


if test "$str" = "today"; then 

    echo "[Weather for today in Norway] 
    Sol, noe overskyet 
    [Vind fra sørøst] 
    Ha en fin dag!" | gammu-smsd-inject TEXT $tlf -unicode -autolen 200 
else 
    echo "fail" >> /home/mattis/sms.txt 
fi 

我這是怎麼開始的守護

$ sudo gammu-smsd 

這工作,如果我使用測試輸入,從終端上運行bash腳本,但是當節目監務-smsd調用我得到的腳本。

gammu-smsd[3183]: Process failed with exit status 2 

現在我可以從代碼中刪除「監務-SMSD-注入」,並以「監務sendsms」取代,但這只是給我的廢話,而不是字母「æøå和[]」收到回時移動。

希望得到積極的答案。

+0

即使我遇到這個問題,我已經填入https://github.com/gammu/gammu/issues/39 – Darick

回答

1

-// - 工作代碼 -// -

的事情是:監務短信注入acctually將數據發送到MySQL數據庫稱爲SMSD。

創建此數據庫: 應按照wammu sql database中的說明創建。存儲用於在MySQL數據庫中創建表的SQL腳本將能夠使用phpmyadmin(gui)或任何其他方式導入它以連接mysql。在收到

運行添加到/ etc /監務,smsdrc --configuration文件的結尾監務

runOnRecieve = /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 

啓動守護程序

$ sudo gammu-smsd 

這應該是它!

額外提示:

  • 使用$ gammu-detect找出設備連接的位置。尋找name = Phone on USB serial port HUAWEI_Technology HUAWEI_Mobile或類似的東西。把這個信息放在配置文件中。
  • 請務必向bashfile添加正確的權限。使運行gammu-smsd的用戶可讀。
  • 使用chmod u + x/path/to/bash/file創建bashfile可執行文件。
  • gammu-smsd-monitor可以用來檢查你有多好的信號。當試圖運行這個時,請不要停止運行gammu-smsd。
  • 您可以通過將虛擬tlf和dummytext作爲輸入運行來測試bashfile。 $ ./bashfile.sh
相關問題