title: gammu-smsd RunOnReceive script results exit status 2
body: <p>I want to forward an SMS using gammu-smsd RunOnReceive.</p>
  
  <p><strong>That is the script I want to run</strong> (/var/spool/gammu/forward.sh) and it goes perfectly if I run it from a sudoer or using <code>sudo -u gammu -g gammu /var/spool/gammu/forward.sh</code></p>
  
  <pre><code>#!/bin/bash
  
  SMS_MESSAGES=1
  
  for i in `seq $SMS_MESSAGES`
  do
      number="SMS_${i}_NUMBER"
      text="SMS_${i}_TEXT"
      eval "gammu-smsd-inject TEXT my_number_goes_here -text \"${!number}: ${!text}\""
  done
  </code></pre>
  
  <p><strong>And here is the problem I am experiencing:</strong></p>
  
  <pre><code>Thu 2015/01/29 23:08:57 gammu-smsd[2549]: Starting run on receive: /var/spool/gammu/forward.sh IN20150130_000850_00_+37368214400_00.txt 
  Thu 2015/01/29 23:08:57 gammu-smsd[2154]: Process failed with exit status 2
  </code></pre>
  
  <p><strong>Output of <code>ls -l /etc/gammu-smsdrc /var/spool/gammu/ /usr/bin/gammu-smsd*</code></strong>:</p>
  
  <pre><code>-rw-r--r-- 1 root root   457 Jan 29 22:44 /etc/gammu-smsdrc
  -rwxrwxrwx 1 root root 14336 Jun 10  2012 /usr/bin/gammu-smsd
  -rwxrwxrwx 1 root root 51164 Jun 10  2012 /usr/bin/gammu-smsd-inject
  -rwxrwxrwx 1 root root  9972 Jun 10  2012 /usr/bin/gammu-smsd-monitor
  
  /var/spool/gammu/:
  total 24
  drwxrwxrwx 2 gammu gammu 4096 Jan 28 16:02 error
  -rwxrwxrwx 1 gammu gammu  189 Jan 29 22:13 forward.sh
  drwxrwxrwx 2 gammu gammu 4096 Jan 29 23:08 inbox
  -rw-rw-r-- 1 gammu gammu 3702 Jan 29 23:08 log
  drwxrwxrwx 2 gammu gammu 4096 Jan 29 23:07 outbox
  drwxrwxrwx 2 gammu gammu 4096 Jan 29 23:07 sent
  </code></pre>
  
  <p><strong>What happens if I just do <code>./forward.sh</code> (not root) - so all is OK:</strong></p>
  
  <pre><code>gammu-smsd-inject[2606]: Created outbox message OUTC20150029_231213_00_my_number_here_sms0.txt
  Written message with ID /var/spool/gammu/outbox/OUTC20150029_231213_00_my_number_here_sms0.txt
  </code></pre>
  
  <p><strong>Here is my /etc/gammu-smsdrc</strong></p>
  
  <pre><code># Configuration file for Gammu SMS Daemon
  
  [gammu]
  port = /dev/ttyUSB0
  connection = at
  
  [smsd]
  service = files
  
  logfile = /var/spool/gammu/log
  
  debuglevel = 2
  
  commtimeout = 1
  sendtimeout = 15
  statusfrequency = 0
  
  outboxformat = unicode
  transmitformat = unicode
  
  RunOnReceive = /var/spool/gammu/forward.sh
  
  inboxpath = /var/spool/gammu/inbox/
  outboxpath = /var/spool/gammu/outbox/
  sentsmspath = /var/spool/gammu/sent/
  errorsmspath = /var/spool/gammu/error/
  </code></pre>
  
  <p><code>ps -fe | grep gammu</code>:</p>
  
  <pre><code>gammu     2154     1  0 23:05 ?        00:00:02 /usr/bin/gammu-smsd --daemon --user gammu --pid /var/run/gammu-smsd.pid
  cubie     2644  2403  0 23:20 pts/0    00:00:00 grep gammu
  </code></pre>
  
  <p>Please, help </p>