SMS Server Tools 3
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. The forum is currently read-only, but will open soon. Fri Nov 22, 2024 05:13
SMSTools3 Community » Help and support Bottom

[solved] GSM1: ALERT: problem with eventhandler

Login and Post Reply

Page:  1

Author Post
Member
Registered:
Mar 2017
Location: Germany
Operating system name and version: 2017-01-11-raspbian-jessie
Version of smsd: 3.1.15-1.1+debu1
Smsd installed from: package repository ..
Name and model of a modem / phone: HUAWEI E398
Interface: / USB


I try to use the smsscript.sh (-rwxr-xr-x 1 root staff 827 Mär 6 21:55 smsscript.sh)

#!/bin/bash
PASSWORD="XYZ"

if [ "$1" = "RECEIVED" ]; then

    TEXT=`sed -e '1,/^$/ d' < $2`
    # Make text uppercase:
    TEXT=`echo "$TEXT" | tr "a-z" "A-Z"`

    RCVPASS=`echo "$TEXT" | cut -d" " -f1`
    ACTION=`echo "$TEXT" | cut -d" " -f2`

    if [ "$PASSWORD" = "$RCVPASS" ]; then
        case $ACTION in

            #Reboot Server
            REBOOT)
                reboot
            ;;

            #Shutdown Server
            SHUTDOWN)
                shutdown -h now
            ;;

            #Reboot DDWRT Router
            REBOOTROUTER)
                plink root@routerip -pw passwort "reboot"
            ;;

            #Reconnect DDWRT Router
            RECONNECTROUTER)
                plink root@routerip -pw passwort "stopservice wan && startservice wan"
            ;;  

        esac
    fi
fi
 
 
'bash' Syntax Highlight powered by GeSHi


when this sms comes in

From: my-phone
From_TOA: 91 international, ISDN/telephone
From_SMSC: 491710760000
Sent: 17-03-07 10:59:02
Received: 17-03-07 10:59:26
Subject: GSM1
Modem: GSM1
IMSI: 262021805294427
Report: no
Alphabet: ISO
Length: 10

XYZ reboot
'sms' Syntax Highlight powered by GeSHi


i get this log entry

2017-03-07 10:59:26,3, GSM1: Done: eventhandler, execution time 0 sec., status: 256 (1)
2017-03-07 10:59:26,3, GSM1: Exec: eventhandler encountered errors:
2017-03-07 10:59:26,3, GSM1: ! Failed to execute operation: Access denied
2017-03-07 10:59:26,3, GSM1: ! Must be root.
2017-03-07 10:59:26,3, GSM1: ALERT: problem with eventhandler, result 1

What's wrong > ok it's me :mrgreen:

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Edit /etc/default/smstools and change USER="root".

Member
Registered:
Mar 2017
Location: Germany
Topic owner
it looks like it's still set

-rw-r--r-- 1 root root 262 Jun 6 2015 smstools

Member
Registered:
Mar 2017
Location: Germany
Topic owner
sorry german expression

wer lesen kann ist eindeitig im vorteil.

thanks

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Inside the file /etc/default/smstools there is a line: USER="smsd". Change that line.

For example after editing the file has a content:
# smsd default file

# Defines under which user smsd is running. This may need to be changed
# if using devices other then /dev/ttyS0
USER="root"
GROUP="dialout"

# Specifies pathes.
PIDFILE="/var/run/smstools/smsd.pid"
INFOFILE="/var/run/smstools/smsd.working"
 
'bash' Syntax Highlight powered by GeSHi


Member
Registered:
Mar 2017
Location: Germany
Topic owner
Thanks now I got it

Member
Registered:
Mar 2017
Location: Germany
Topic owner
Now i get this in the logfile


Smsd mainprocess is awaiting the termination of all modem handlers. PID: 727.
2017-03-09 10:34:39,2, GSM1: Modem handler 0 terminated. PID: 728, was started 17-03-09 10:26:41.
2017-03-09 10:34:43,2, smsd: Smsd v3.1.15 started.
2017-03-09 10:34:43,2, smsd: Running as root:root.
2017-03-09 10:34:43,4, smsd: File mode creation mask: 022 (0644, rw-r--r--).
2017-03-09 10:34:43,3, GSM1: Couldn't open serial port /dev/ttyUSB0, error: No such file or directory, waiting 30 sec.

I have no idea

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
First ensure that smsd is not running. Disconnect the modem, and connect it back. Use dmsg to see what ports are created. If there is nothing to see, wait a moment and use dmesg again. There should be three ports seen, and the first one should be used.

Instead of using the first port directly, use a link for it. Check which links are available:
ls -ltr /dev/serial/by-id/

There may be something like this:
usb-HUAWEI_HUAWEI_Mobile-if00-port0 -> ../../ttyUSB0

Check which link points to the first ttyUSB port, and use that link, like:

[GSM1]
device = /dev/serial/by-id/usb-HUAWEI_HUAWEI_Mobile-if00-port0


When a modem disconnects and is connected back again, sometimes the ttyUSB port is not the same as before. /dev/serial/by-id/xxx link remains the same, so it's better to use it.


« Last edit by keke on Thu Mar 09, 2017 21:01, 93 months ago. »
Member
Registered:
Mar 2017
Location: Germany
Topic owner
thanks for your help this are the results

lrwxrwxrwx 1 root root 13 Mär 9 16:35 usb-HUAWEI_HUAWEI_Mobile-if00-port0 -> ../../ttyUSB0

2017-03-09 16:43:00,2, smsd: Smsd v3.1.15 started.
2017-03-09 16:43:00,2, smsd: Running as root:root.
2017-03-09 16:43:00,4, smsd: File mode creation mask: 022 (0644, rw-r--r--).
2017-03-09 16:43:00,3, GSM1: Couldn't open serial port /dev/serial/by-id/usb-HUAWEI_HUAWEI_Mobile_if00-port0, error: No such file or directory, waiting 30 sec.
2017-03-09 16:43:30,3, GSM1: Cannot open serial port /dev/serial/by-id/usb-HUAWEI_HUAWEI_Mobile_if00-port0, error: No such file or directory
2017-03-09 16:43:30,2, GSM1: Modem handler 0 terminated. PID: 1155, was started 17-03-09 16:43:00.


for me it looks like that this doesn't help ?????

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
You should copy the name of the symlink from your system, not from my post which was just an example.

smsgina wrote
lrwxrwxrwx 1 root root 13 Mär 9 16:35 usb-HUAWEI_HUAWEI_Mobile-if00-port0 -> ../../ttyUSB0

Assuming that this was copy-pasted from you system, your setting should be:
device = /dev/serial/by-id/usb-HUAWEI_HUAWEI_Mobile-if00-port0

Notice that ... Mobile <minus> if00 ... (I colorized it, and also fixed the lines in my post, because some another may later use that example and get the same error).

Member
Registered:
Mar 2017
Location: Germany
Topic owner
I did the procedure again, this are copy + paste results


dmesg

[ 17.925144] usbserial: USB Serial support registered for GSM modem (1-port)
[ 17.925483] option 1-1.4:1.0: GSM modem (1-port) converter detected
[ 17.925812] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB0
[ 17.925906] option 1-1.4:1.1: GSM modem (1-port) converter detected
[ 17.926208] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB1
[ 17.926276] option 1-1.4:1.2: GSM modem (1-port) converter detected
[ 17.926525] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB2


ls -ltr /dev/serial/by-id/

lrwxrwxrwx 1 root root 13 Mär 9 16:51 usb-HUAWEI_HUAWEI_Mobile-if02-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Mär 9 16:51 usb-HUAWEI_HUAWEI_Mobile-if01-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Mär 9 16:51 usb-HUAWEI_HUAWEI_Mobile-if00-port0 -> ../../ttyUSB0

[GSM1]
#init =
device = /dev/serial/by-id/usb-HUAWEI_HUAWEI_Mobile-if00-port0
incoming = yes



log

2017-03-10 17:08:45,2, smsd: Smsd mainprocess is awaiting the termination of all modem handlers. PID: 764.
2017-03-10 17:08:45,2, smsd: Smsd mainprocess terminated. PID 764, was started 17-03-09 16:51:15.
2017-03-10 17:08:50,2, smsd: Smsd v3.1.15 started.
2017-03-10 17:08:50,2, smsd: Running as root:root.
2017-03-10 17:08:50,4, smsd: File mode creation mask: 022 (0644, rw-r--r--).
2017-03-10 17:08:50,3, GSM1: Couldn't open serial port /dev/serial/by-id/usb-HUAWEI_HUAWEI_Mobile-if00-port0, error: No such file or directory, waiting 30 sec.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
I have to say that I do not understand what is going on now. :shock: Settings looks good, and the symlink exists. Still you get "No such file or directory". I assume that you did not remove the modem after listing those symlinks.

I tested this issue with raspberry pi3 running raspbian-jessie and smsd 3.1.15 installed from repository. Everything works like a charm, with privileges of root or smsd, and with symlink or direct path to ttyUSB0. Strange? :roll:

Next you could go back to the start point. Restore USER="smsd" to /etc/default/smstools, and in the configuration use /dev/ttyUSB0. Then everything should work, as worked before changes were made.

When running smsd as smsd:dialout, eventhandler cannot contain commands which require root privileges. This was the initial problem. For those commands, at least reboot and shutdown, create an external script which is polled by the cron job. Something like: when a cron job sees the script, it is executed. Or even better, write the command to the "flag file", and when cron job reads that file, it can verify that the command is acceptable, and then executes it. Thus, in principle, there are many ways of implementation.

Hope you did not get too confused... ;)

Member
Registered:
Mar 2017
Location: Germany
Topic owner
thanks for yous help .
i will setup the system from the beginnig, because i tried a lot of different sings .

i hope this will help.

best greetings rudi

Member
Registered:
Mar 2017
Location: Germany
Topic owner
hello keke,

i did a new system setup and the reboot or shutdown option are ok.
after that i changed the original script.

#!/bin/bash
PASSWORD="XYZ"

if [ "$1" = "RECEIVED" ]; then

    TEXT=`sed -e '1,/^$/ d' < $2`
    # Make text uppercase:
    TEXT=`echo "$TEXT" | tr "a-z" "A-Z"`

    RCVPASS=`echo "$TEXT" | cut -d" " -f1`
    ACTION=`echo "$TEXT" | cut -d" " -f2`

    if [ "$PASSWORD" = "$RCVPASS" ]; then
        case $ACTION in

            #Reboot Server
            REBOOT)
                reboot
            ;;

            #Shutdown Server
            SHUTDOWN)
                shutdown -h now
            ;;

            #Interface ppp0 up
            IFUP)
                ifup ppp0            
            ;;

            #Interface ppp0 down
            IFDOWN)
                ifdown ppp0
            ;;  

        esac
    fi
fi
 
 
'bash' Syntax Highlight powered by GeSHi


i like to control the ifup and ifdown interface .
the ifup option is running well.
but for ifdown no sms will accept in the incomming folder ???

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Smsd itself does not use the network. If you have some external network interface to create outgoing files, it of course does not work if the network is down. For local spooling of messages it makes no difference if network is up or not.

Member
Registered:
Mar 2017
Location: Germany
Topic owner
Sorry , but i looks like that can not describe the problem.
In this eventhandler - script are 4 ACTION

REBOOT
SHUTDOWN
IFUP
IFDOWN

Sending SMS with ACTION REBOOT or SHUTDOWN or IFUP the related ACTION will execute.

Sending SMS IFDOWN nothing happend and the SMS will not be shoen in the incomming folder.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
So you send XYZ IFUP, and it works. And when you send XYZ IFDOWN, the SMS is never received? :shock: If you are completely sure that the SMS was sent to the correct number, and it really is not received, then you should contact your operator. They perhaps have some "badword blocking list" in use, and SMS containing a word IFDOWN is not delivered. :roll:

Member
Registered:
Mar 2017
Location: Germany
Topic owner
Sorry i checked it again.

after receiving XYZ IFUP no further SMS will reveived. ????

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Does it help if you disconnect and reconnect the modem, so it gets hardware reset?

If you still cannot receive any messages, test the SIM with a handset to see how it works.

If the problem still exists, please contact your network operator, or at least test with a new SIM.

Member
Registered:
Mar 2017
Location: Germany
Topic owner
I got the solution.

The command ifup ppp0 builds a connection via the interface ppp0.
Now the modem is occupied and no further action possible.

Thanks for your help and perseverance.

Login and Post Reply

Page:  1

SMSTools3 Community » Help and support Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.