【问题标题】:Recieve and reply to sms on huawei modem, gammu-smsd: Process failed with exit status 2在华为调制解调器 gammu-smsd 上接收和回复短信:进程失败,退出状态 2
【发布时间】:2015-03-19 23:45:50
【问题描述】:

我在 Linux xubuntu 上有一个华为 E220 HSDPA 调制解调器 我想收到短信并自动回复给发件人。 我使用 gammu 和 Gammu-smsd 来做到这一点。

为了自动发回短信,我将 runOnRecieve = /path/to/bash/file 添加到 /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 脚本,则此方法有效,但是当程序 gammu-smsd 调用我得到的脚本时。

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

现在我可以从代码中删除 "gammu-smsd-inject" 并替换为 "gammu sendms" ,但这只会在收到回手机时给我乱码而不是 "æøå 和 [ ]"。

希望得到肯定的答复。

【问题讨论】:

标签: bash unicode sms modem gammu


【解决方案1】:

--//--工作代码--//--

问题是:Gammu sms injection 准确地将数据发送到名为 smsd 的 mysql 数据库。

创建此数据库: 这应该按照wammu sql database 中的指定创建。在 MySQL 数据库中存储用于创建表的 SQL 脚本,您可以使用 phpmyadmin(gui) 或任何其他方式与 mysql 交互。

收到后运行 添加到 /etc/gammu-smsdrc --gammu 配置文件的末尾

runOnRecieve = /path/to/bash/file

打开 /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 或类似的东西。将此信息放入配置文件中。
  • 请务必为 bash 文件添加正确的权限。使其对运行 gammu-smsd 的用户可读。
  • 使用 chmod u+x /path/to/bash/file 使 bashfile 可执行。
  • gammu-smsd-monitor 可用于检查您的信号有多好。尝试运行时,请不要停止运行 gammu-smsd。
  • 您可以通过使用 dummy tlf 和 dummytext 作为输入来运行 bashfile 来测试它。 $ ./bashfile.sh

【讨论】:

    猜你喜欢
    • 2015-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-21
    • 1970-01-01
    • 2014-06-04
    • 2023-04-06
    • 1970-01-01
    相关资源
    最近更新 更多