1

Temat: smstools3 - problem z eventhandler

Zainstalowałem sobie paczkę smstools3 do obsługi smsów. Wszystko działa dobrze, mogę wysyłać i odbierać smsy ale problem pojawia się kiedy chcę uruchomić skrypt do obsługi eventhandler.

skrypt:

#!/bin/sh

if [ $1 != "RECEIVED" ]; then
    exit 0
fi

TEL=$('/^From:/ {print $2}' $2)

if grep -q speedtest $2; then
    echo "To: $TEL" >> /mnt/share/sms
    echo "" >> /mnt/share/sms
    NOW=$(date +"%d-%m-%Y_%T")
    mkdir -p /mnt/share/sms/tmp/sms_$NOW.txt
    LOG=/mnt/share/sms/tmp/sms_$NOW.txt
    python /mnt/share/speedtest/speedtest_cli.py --mini >> $LOG

    mv /mnt/share/sms/tmp /mnt/share/sms/outgoing
fi

if grep -q reboot $2; then
    reboot
fi

exit 0

a log wygląda tak:

2016-08-03 19:05:45,2, smsd: Smsd v3.1.15 started.
2016-08-03 19:05:45,2, smsd: Running as root:root.
2016-08-03 19:05:45,4, smsd: File mode creation mask: 022 (0644, rw-r--r--).
2016-08-03 19:05:45,5, smsd: Outgoing file checker has started. PID: 32588.
2016-08-03 19:05:45,5, GSM1: Modem handler 0 has started. PID: 32590.
2016-08-03 19:05:45,5, GSM1: Using check_memory_method 1: CPMS is used.
2016-08-03 19:05:45,3, GSM1: Unexpected input: ^RSSI:29 ^HCSQ:"LTE",67,63,221,20
2016-08-03 19:05:49,5, GSM1: CGSN: xxxxxxxxxxxxxxxxxxxx
2016-08-03 19:05:49,5, GSM1: IMSI: xxxxxxxxxxxxxx
2016-08-03 19:06:11,3, GSM1: Unexpected input: ^RSSI:27 ^HCSQ:"LTE",63,63,221,28
2016-08-03 19:06:15,5, GSM1: SMS received, From: xxxxxxxxxxx
2016-08-03 19:06:15,3, GSM1: Exec: eventhandler encountered errors:
2016-08-03 19:06:15,3, GSM1: ! /usr/local/bin/sms: line 7: /^From:/ {print $2}: not found
2016-08-03 19:06:15,3, GSM1: ! /usr/local/bin/sms: line 18: can't create /mnt/share/sms: Is a directory
2016-08-03 19:06:15,3, GSM1: ! /usr/local/bin/sms: line 18: can't create /mnt/share/sms: Is a directory
2016-08-03 19:06:15,3, GSM1: ! /usr/local/bin/sms: line 18: can't create /mnt/share/sms/tmp/sms_03-08-2016_19:06:15.txt: Is a directory

ktoś wie jak sobie z tym poradzić?

WinISO.pl - Archiwum polskich wersji systemów Windows, Windows Serwer i Office

2

Odp: smstools3 - problem z eventhandler

awk ci zabrakło. Nie przepisałeś dobrze.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

3

Odp: smstools3 - problem z eventhandler

No to zaszalałem, faktycznie brakło tego polecenia. Był też jeszcze jeden błąd w grep. Powinno być tak:

if grep -q speedtest $2; then
    NOW=$(date +"%d-%m-%Y")
    mkdir -p /mnt/share/sms/tmp/
    echo "To: $TEL" >> /mnt/share/sms/tmp/sms_$NOW.txt
    echo "" >> /mnt/share/sms/tmp/sms_$NOW.txt
    LOG=/mnt/share/sms/tmp/sms_$NOW.txt
    python /mnt/share/speedtest/speedtest_cli.py --simple >> $LOG
    mv /mnt/share/sms/tmp/sms_$NOW.txt /mnt/share/sms/outgoing
WinISO.pl - Archiwum polskich wersji systemów Windows, Windows Serwer i Office