File: smsresend

package info (click to toggle)
smstools 3.1-2%2Blenny1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,260 kB
  • ctags: 459
  • sloc: ansic: 9,720; sh: 968; php: 115; makefile: 72; awk: 17
file content (37 lines) | stat: -rwxr-xr-x 908 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
# This is an example script that you can use to resent
# failed messages. The script inserts a counter in the message
# file that is used to ensure that the number of retries
# is limited.
# The script does not need any command line arguments.

failed=/var/spool/sms/failed
outgoing=/var/spool/sms/outgoing
max=5

used=0
notused=0
cd $failed
for file in *; do
  if [ "$file" = "*" ]; then
    echo "No failed files found"
    exit 1
  fi
  retry=`formail -zx Retry: < $file`
  if [ "$retry" ]; then
    retry=`expr $retry + 1`
  else
    retry=1
  fi
  if [ $retry -gt $max ]; then
    notused=`expr $notused + 1`
  else
    used=`expr $used + 1`
    mv $file $file.old
    formail -f -I "Retry: $retry" < $file.old > $file
    mv $file $outgoing
    rm $file.old
  fi
done
echo "$used messages moved again into outgoing spool directory"
echo "$notused messages ignored because of to many retries"