First of all, I've managed to configure gammu-smsd on my debian machine in the way I wanted. Now I'm trying to copy the configuration to my router. I installed the gammu package and did some tests. Gammu-smsd works just fine. It receives messages and saves them in files. I can also send SMS via gammu-smsd-inject tool. Although both gammu-smsd and gammu-smsd-inject work just fine, I couldn't force gammu-smsd to work with a simple script.

The gammu config looks like this:

# cat /etc/config/gammu 
config daemon default
    option enabled    '1'
    option device        '/dev/ttyUSB0'
    option connection    'at115200'
    option logfile        'syslog'
    option onreceive    '/etc/skrypty/sms.sh'

I tried to change device to /dev/ttyUSB1 , and also connection to at . The following is the script:

#!/bin/sh

SMS_MESSAGES=1

PROGRAM="/bin/echo -e"

for i in `seq $SMS_MESSAGES`
do
    eval "$PROGRAM \"Number: \${SMS_${i}_NUMBER} | Message: \${SMS_${i}_TEXT}\""
    eval "$PROGRAM \"Numer: \${SMS_${i}_NUMBER}\nWiadomosc: \${SMS_${i}_TEXT}\"" | gammu-smsd-inject --config=/var/gammu-default.conf TEXT +48600123456
done

So when a SMS comes to the E3372s modem, this script should be run. After this, there should be some output in the log that includes the number and the SMS text. Then it should include the number and the original message in a new message and send that to another number. This works fine on my debian. But in the case of my router, I get the following log:

gammu-smsd[9959]: Read 1 messages
gammu-smsd[9959]: Received IN20160426_194331_00_+48600653211_00.txt
gammu-smsd[9983]: Starting run on receive: /etc/skrypty/sms.sh IN20160426_194331_00_+48600654321_00.txt 
gammu-smsd[9959]: Process failed with exit status 1

I have no idea why the "process failed". When I run the script from a terminal, I get the following output:

# ./sms.sh 
Number:  | Message: 
gammu-smsd-inject[10024]: Warning: No PIN code in /var/gammu-default.conf file
gammu-smsd-inject[10024]: Created outbox message OUTC20160426_200453_00_+48600123456_sms0.smsbackup
Written message with ID /var/sms/outbox/OUTC20160426_200453_00_+48600123456_sms0.smsbackup

So the message was passed to gammu-smsd, and after a few seconds in the log I can see this:

gammu-smsd[9959]: Message without SMSC, assuming you want to use the one from phone
gammu-smsd[9959]: Transmitted OUTC20160426_200453_00_+48600123456_sms0.smsbackup (total: 1) to +48600654321, message reference 0xce

And of course I get the SMS on phone.

So the question is why the script fails when called by gammu-smsd and how to fix that?