SMS Server Tools 3
This site is hosted by Kekekasvi.com
 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. Please login or register. Tue Jun 25, 2024 16:27
SMSTools3 Community » Feature requests Bottom

Scheduler for sending messages

Login and Post Reply

Page:  1

Author Post
Member
Registered:
Dec 2010
Location: Poland
Hello Keke:)
My business colleges want to be informed by sms only in exact time intervals, for example Mon-Fri from 8:00 to 16:00.
Do we have any solution already implemented in smsservertools for it or I need to script this by myself?
Little example: we have a corporate service failure on Friday night around midnight which lasts until Monday morning..we don't want to be bothered in the weekend so we should get an sms on Monday morning according to time intervals from above (Mon-Fri from 8:00 to 16:00).

Thanks in advance,
Peter

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
There is some sample available, but it does not do exactly what you want. However, let's see it first: this is from smstools3/scripts/regular_run script:

#!/bin/bash

SCHEDULEDDIR=/var/spool/sms/scheduled
OUTGOINGDIR=/var/spool/sms/outgoing

if [ "$(ls -A $SCHEDULEDDIR)" ]; then
  TMPFILE=`mktemp /tmp/smsd_XXXXXX`
  #grep -l ^Send: $SCHEDULEDDIR/* > $TMPFILE
  grep -l ^To: $SCHEDULEDDIR/* > $TMPFILE
  cat $TMPFILE | while read FNAME; do

    schedule=`formail -zx Send: < ${FNAME}`
    if [ "x$schedule" != "x" ]; then
      cur_timestamp=`date +%s`
      schedule_timestamp=`date +%s -d "$schedule"`
      time_diff=$(($schedule_timestamp - $cur_timestamp))
      if [ $time_diff -lt 0 ]; then
        mv ${FNAME} $OUTGOINGDIR
      fi
      continue
    fi
  done
  unlink $TMPFILE
fi

exit 0
 
'bash' Syntax Highlight powered by GeSHi


The script could be saved as /usr/local/bin/smsd_regular_run and the following settings are required in the global part of smsd.conf:

regular_run = /usr/local/bin/smsd_regular_run
regular_run_interval = 60


Scheduled messages are placed into the /var/spool/sms/scheduled directory, instead of outgoing directory. All scheduled messages contain additional header, which tells when SMS should be sent. For example:

Send: 2011-12-01 08:00:00
To: 358401234567

Do not forget the meeting today afternoon!
'sms' Syntax Highlight powered by GeSHi


Once per minute smsd will run the script, and if it finds SMS which should be sent, it moves the file to the outgoing directory.

In your case you likely need to write a script which has more intelligence. For example the checkhandler could check if the time is outside from 8 to 16, or day is Saturday or Sunday, and decide if SMS should be moved to scheduled directory with a new header which tells the sending time. The regular_run then moves messages back when it's the time.

Anyways, there are some other options available too (stop the daemon when not to bother, or put a modem to suspend state), but complete implementation for you is not yet done, as far as I know.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Well, your idea was good and I had to think this more deeply... ;) I actually had some pieces of a code in my mail server, where incoming mail was notified using SMS.

Here is the implementation for smstools3. It differs slightly from your definition, but generally taken does the same.

Messages which may be scheduled to be sent later should have an additional header: Urgency: low. Without this header message is sent without delays.

The original sample of checkhandler which handles multiple recipients needs some additions (highlighted):

#!/bin/bash
 
# Sample script to allow multiple recipients in one message file.
# Define this script as a checkhandler.
 
outgoing="/var/spool/sms/outgoing"
scheduler="/usr/local/bin/smsd_scheduler.sh"

recipients=`formail -zx "To:" < "$1"`
 
#count=`echo "$recipients" | wc -l`
count=`echo "$recipients" | wc -w`
if [ $count -gt 1 ]; then
 
  # Will need echo which accepts -n argument:
  ECHO=echo
  case `uname` in
    SunOS)
      ECHO=/usr/ucb/echo
      ;;
  esac
 
  messagebody=`sed -e '1,/^$/ d' < "$1"`
  headers=`formail -X "" -I "To:" -f < "$1"`
 
  for recipient in $recipients
  do
    file=`mktemp $outgoing/send_XXXXXX`
    $ECHO "To: $recipient" > $file
    if [ "x$headers" != "x" ]; then
      $ECHO "$headers" >> $file
    fi
    $ECHO "" >> $file
    $ECHO -n "$messagebody" >> $file
  done
 
  # Remove processed file:
  rm $1
 
  # Tell to smsd that checkhandler has spooled this message:
  exit 2

else

  # Run scheduler:
  $scheduler "$1"
  i=$?
  exit $i

fi
 
exit 0
 
 
'c' Syntax Highlight powered by GeSHi


The script /usr/local/bin/smsd_scheduler.sh:

#!/bin/bash

silence_conf="/etc/sms_silence.conf"
scheduled_dir="/var/spool/sms/scheduled"

#--------------------------------------------------------------------------
date2stamp()
{
  local DATE="$1"

  [ -z "$DATE" ] && DATE=$(date +"%Y-%m-%d %T")
  date --utc --date "$DATE" +%s
}

#--------------------------------------------------------------------------
stamp2date()
{
  date --utc --date "1970-01-01 $1 sec" "+%Y-%m-%d %T"
}

#--------------------------------------------------------------------------
is_time_between()
{
  # $1 = time
  # $2 = later time
  # $3 = optional: time to test (timestamp)

  local DATE
  local stamp stamp1 stamp2
  local result=0

  if [ -n "$3" ]; then
    DATE=$(stamp2date "$3")
  else
    DATE=$(date +"%Y-%m-%d %T")
  fi

  stamp=$(date2stamp "$DATE")
  stamp1=$(date2stamp "${DATE:0:10} $1")
  stamp2=$(date2stamp "${DATE:0:10} $2")

  if [ $stamp2 -le $stamp1 ]; then
    if [ $stamp -le $stamp2 ]; then
      stamp1=$(($stamp1 - 86400))
    else
      stamp2=$(($stamp2 + 86400))
    fi
  fi

  [ $stamp -ge $stamp1 ] && [ $stamp -le $stamp2 ] && result=1

  echo "$result"
}

#--------------------------------------------------------------------------
test_silence()
{
  # $1 = timestamp
  # $2 = definition of silence

  local result=0
  local timestamp="$1"
  local silence="$2"
  local tmp

  if [[ "$silence" == *$'-'* ]]; then
    silence=${silence// /}
    tmp=$(is_time_between "${silence:0:5}:00" "${silence:6:5}:00" "$timestamp")
    [ $tmp -gt 0 ] && result=1
  else
    tmp=$(date --utc --date "1970-01-01 $timestamp sec" +"%H")
    if [[ "$silence" == *${tmp}* ]]; then
      result=1
    fi
  fi

  if [ $result -eq 0 ]; then
    tmp=$(date --utc --date "1970-01-01 $timestamp sec" +"%a" | tr a-z A-Z)
    if [[ "$silence" == *${tmp}* ]]; then
      result=1
    fi
  fi

  echo "$result"
}

#--------------------------------------------------------------------------
remove_header()
{
  # $1 = filename
  # $2 = header

  local tmp=$(formail -zx "$2" < "$1")
  if [ -n "$tmp" ]; then
    tmp=$(mktemp /tmp/smsd__XXXXXX)
    cp "$1" $tmp
    formail -f -I $2 < $tmp > "$1"
    unlink $tmp
  fi
}

#--------------------------------------------------------------------------
set_header()
{
  # $1 = filename
  # $2 = header

  local tmp=$(mktemp /tmp/smsd_XXXXXX)
  cp "$1" $tmp
  formail -f -I "$2" < $tmp > "$1"
  unlink $tmp
}

#--------------------------------------------------------------------------

urgency=$(formail -zx Urgency: < $1 | tr a-z A-Z)

if [ "$urgency" = "LOW" ]; then

  TO=$(formail -zx To: < $1)
  silence=$(formail -zx ${TO}: < "$silence_conf")
  [ -z "$silence" ] && silence=$(formail -zx DEFAULT: < "$silence_conf")

  if [ -n "$silence" ]; then
    DATE=$(date +"%Y-%m-%d %T")
    timestamp=$(date2stamp "$DATE")
    tmp=$(test_silence "$timestamp" "$silence")

    if [ $tmp -gt 0 ]; then
      DATE="${DATE:0:14}00:01"
      timestamp=$(date2stamp "$DATE")
      timestamp=$(($timestamp + 3600))
      stampmax=$(($timestamp + 604800))

      while [ $timestamp -lt $stampmax ]; do
        tmp=$(test_silence "$timestamp" "$silence")
        if [ $tmp -eq 0 ]; then
          break
        fi
        timestamp=$(($timestamp + 3600))
      done

      if [ $timestamp -ge $stampmax ]; then
        echo "ERROR. Definition of silence is not valid."
        exit 1
      else
        DATE=$(stamp2date "$timestamp")

        set_header "$1" "Send: $DATE"
        set_header "$1" "Silence: $silence"
        set_header "$1" "Spooled: $(date +"%Y-%m-%d %T")"
        remove_header "$1" "Urgency:"

        mv $1 $scheduled_dir
      fi

      exit 2
    fi
  fi

fi

exit 0
 
 
'bash' Syntax Highlight powered by GeSHi


Now the file /etc/sms_silence.conf, for example:



In this file there is a GSM number as a header, and definition of silence as a value. Special header DEFAULT is used, if a GSM number has no it's own definition. If definition contains minus sign, it is assumed that the definition begins with a "HH:MM - HH:MM" range. Only one range can be defined. If there is no minus sign, it is assumed that hours are listed as in the DEFAULT case. Additionally short names of weekdays can be defined too.

Now, when outgoing SMS is like:

To: 358401111111 358402222222
To: 358403333333
Urgency: low

This is an alarm from the server.
'sms' Syntax Highlight powered by GeSHi


...checkhandler will first create single SMS file for each recipient, and tell to smsd that SMS was spooled by the checkhandler. Next smsd will find files with single recipient, and scheduler is executed for each file. If there is "Urgency: low" header and sms_silence.conf defines that message should be sent later, the script will find the first possible time to send and moves message file to the scheduled directory.

Scheduled files will have some additional information, for example:

To: 358401234567
Send: 2011-01-16 08:00:01
Silence: 16:00 - 08:00 MON TUE WED THU FRI SAT
Spooled: 2011-01-12 13:16:35

This is an alarm from the server.
'sms' Syntax Highlight powered by GeSHi


Simply, "Spooled" tell when the SMS was handled, and "Silence" tells what was the definition when SMS was scheduled. This allows that later some external script can poll scheduled messages, and if some definition of silence has changed, SMS can be sent earlier or later what was originally defined. This implementation is not included in this post.

Next, regular_run shown in post #2 is required, as it will handle messages later.

In some servers smsd_scheduler.sh may be very slow, because bash script is not the fastest possible. If continuous time of silence is very long, it may take couple of seconds to find the first allowed time to send. If PHP is available, here is the version of scheduler which is much more faster:

#!/usr/bin/php
<?php

$silence_conf = "/etc/sms_silence.conf";
$scheduled_dir = "/var/spool/sms/scheduled";

//-------------------------------------------------------------------------
function date2stamp($str = "")
{
  $dt = $str;

  if (empty($dt))
    $dt = date("Y-m-d H:i:s");

  return strtotime($dt);
}

//-------------------------------------------------------------------------
function stamp2date($value)
{
  return date("Y-m-d H:i:s", $value);
}

//-------------------------------------------------------------------------
function is_time_between($time1, $time2, $time_to_test = 0)
{
  $result = 0;

  if ($time_to_test)
    $dt = stamp2date($time_to_test);
  else
    $dt = date("Y-m-d H:i:s");

  $stamp = date2stamp($dt);
  $stamp1 = date2stamp(substr($dt, 0, 10) ." " .$time1);
  $stamp2 = date2stamp(substr($dt, 0, 10) ." " .$time2);

  if ($stamp2 <= $stamp1)
  {
    if ($stamp <= $stamp2)
      $stamp1 -= 86400;
    else
      $stamp2 += 86400;
  }

  if ($stamp >= $stamp1 && $stamp <= $stamp2)
    $result = 1;

  return $result;
}

//-------------------------------------------------------------------------
function test_silence($timestamp, $silence)
{
  $result = 0;

  if (strpos($silence, "-") !== false)
  {
    $silence = str_replace(" ", "", $silence);
    $time1 = substr($silence, 0, 5) .":00";
    $time2 = substr($silence, 6, 5) .":00";
    if (is_time_between($time1, $time2, $timestamp))
      $result = 1;
  }
  else
  {
    $tmp = date("H", $timestamp);
    if (strpos($silence, $tmp) !== false)
      $result = 1;
  }

  if (!$result)
  {
    $tmp = strtoupper(date("D", $timestamp));
    if (strpos($silence, $tmp) !== false)
      $result = 1;
  }

  return $result;
}

//-------------------------------------------------------------------------

$exitvalue = 0;

$sms_file = $argv[1];
$sms_file_content = file_get_contents($sms_file);
$i = strpos($sms_file_content, "\n\n");
$sms_headers_part = substr($sms_file_content, 0, $i);
$sms_message_body = substr($sms_file_content, $i + 2);
$sms_header_lines = split("\n", $sms_headers_part);
$sms_headers = array();

foreach ($sms_header_lines as $header)
{
  $i = strpos($header, ":");
  if ($i !== false)
    $sms_headers[substr($header, 0, $i)] = substr($header, $i + 2);
}

//-------------------------------------------------------------------------

if (isset($sms_headers['Urgency']) && strtoupper($sms_headers['Urgency']) == "LOW")
{
  $silence_file_content = file_get_contents($silence_conf);
  $i = strpos($silence_file_content, "\n\n");
  if ($i !== false)
    $silence_headers_part = substr($silence_file_content, 0, $i);
  else
    $silence_headers_part = $silence_file_content;
  $silence_header_lines = split("\n", $silence_headers_part);
  $silence_headers = array();

  foreach ($silence_header_lines as $header)
  {
    $i = strpos($header, ":");
    if ($i !== false)
      $silence_headers[substr($header, 0, $i)] = substr($header, $i + 2);
  }

  $silence = "";

  if (isset($silence_headers[$sms_headers['To']]))
    $silence = $silence_headers[$sms_headers['To']];
  else
  if (isset($silence_headers['DEFAULT']))
    $silence = $silence_headers['DEFAULT'];

  if (!empty($silence))
  {
    $dt = date("Y-m-d H:i:s");
    $timestamp = date2stamp($dt);
    if (test_silence($timestamp, $silence) > 0)
    {
      $dt = substr($dt, 0, 14) ."00:01";
      $timestamp = date2stamp($dt);
      $timestamp += 3600;
      $stampmax = $timestamp + 604800;

      while ($timestamp < $stampmax)
      {
        if (!test_silence($timestamp, $silence))
          break;
        $timestamp += 3600;
      }

      if ($timestamp >= $stampmax)
      {
        echo "ERROR. Definition of silence is not valid.";
        $exitvalue = 1;
      }
      else
      {
        $dt = stamp2date($timestamp);
        $sms_headers['Send'] = $dt;
        $sms_headers['Silence'] = $silence;
        $sms_headers['Spooled'] = date("Y-m-d H:i:s");
        unset($sms_headers['Urgency']);

        $sms_file_content = "";
        foreach ($sms_headers as $key => $val)
          $sms_file_content .= $key .": " .$val ."\n";
        $sms_file_content .= "\n";
        $sms_file_content .= $sms_message_body;

        $new_sms_file = $scheduled_dir .strrchr($sms_file, '/');

        //Not in PHP 4: file_put_contents($new_sms_file, $sms_file_content);
        if (($handle = fopen($new_sms_file, "w")) !== false)
        {
          fwrite($handle, $sms_file_content);
          fclose($handle);
        }

        unlink($sms_file);

        $exitvalue = 2;
      }
    }
  }
}

exit($exitvalue);
?>
 
 
'php' Syntax Highlight powered by GeSHi


Finally, as an example, an eventhandler which can be used for the maintenance of silence definitions:

#!/bin/bash

silence_conf="/etc/sms_silence.conf"
scheduler="/usr/local/bin/smsd_scheduler.sh" # Change if using PHP

#--------------------------------------------------------------------------
send_sms()
{
  # $1 = To
  # $2 = Message
  # $3 = Provider (optional)

  local FILE=$(mktemp /tmp/smsd_send_XXXXXX)
  echo "To: $1" >> $FILE
  if [ "x$3" != "x" ]; then
    echo "Provider: $3" >> $FILE
  fi
  echo "Comment: smsd eventhandler auto-answer" >> $FILE
  echo "" >> $FILE
  echo -n "$2" >> $FILE
  local FILE2=`mktemp /var/spool/sms/outgoing/send_XXXXXX`
  mv $FILE $FILE2
}

#--------------------------------------------------------------------------
set_header()
{
  # $1 = filename
  # $2 = header

  local tmp=$(mktemp /tmp/smsd_eventhandler_XXXXXX)
  cp "$1" $tmp
  formail -f -I "$2" < $tmp > "$1"
  unlink $tmp
}

#--------------------------------------------------------------------------

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

  FROM=$(formail -zx From: < $2)
  TEXT=$(sed -e '1,/^$/ d' < $2)
  keyword=$(echo ${TEXT:0:8} | tr a-z A-Z)

  if [ "$keyword" = "SILENCE?" ]; then
    silence=$(formail -zx ${FROM}: < "$silence_conf")
    if [ -z "$silence" ]; then
      silence=$(formail -zx DEFAULT: < "$silence_conf")
    fi

    if [[ "$scheduler" == *$'.sh' ]]; then
      days=""
      for ((i = 12; i < 19; i++)); do
      [ -n "$days" ] && days="$days "
      days="${days}$(date --utc --date "1970-01-${i}" "+%a")"
      done
      days=$(echo "$days" | tr a-z A-Z)
    else
      days="MON TUE WED THU FRI SAT SUN"
    fi

    if [ -z "$silence" ]; then
      message="Silence not set"
    else
      message="Silence: $silence"
    fi

    send_sms $FROM "$message (Abbreviated names of the days: $days)"

  elif [ "$keyword" = "SILENCE:" ]; then
    silence=$(echo ${TEXT:8} | tr a-z A-Z)
    [ -n "$silence" ] && silence=" $silence"
    set_header "$silence_conf" "${FROM}:$silence"
    tmp=${silence// /}
    if [ -z "$tmp" ]; then
      silence=" DEFAULT"
    fi

    send_sms $FROM "Silence set to:$silence"

  fi
fi

exit 0
 
 
'bash' Syntax Highlight powered by GeSHi


When SMS starting with "Silence?" is received, eventhandler will send an answer containing current setting and list of abbreviated names of the days. Received SMS starting with "Silence:" sets the definition.

Member
Registered:
Dec 2010
Location: Poland
Topic owner
Hello Keke,
Thanks for Your support - I'm sure that I'm not the only one who will use it:)
With some friends @ work we are currently working on another way to achieve scheduler functionality - I will of course post it when we will finish testing.

Best regards,
Peter

Member
Registered:
Dec 2010
Location: Poland
Topic owner
Hello again,
I'd like to share another way to achieve scheduler functionality used in our environment (Smsd v3.1.14 on Centos 5.5)

1)Directories&Localizations:

a)/var/spool/sms/temp/ - initial directory where not divided smses are placed;
b)/var/spool/sms/scheduler/ - directory where divided smses are moved from a) by smsd_multisms.sh to be checked according to scheduler settings by scheduler.sh;
c)/var/spool/sms/outgoing/ - final directory where smses from b) are moved to be send;
d)/usr/local/bin/smsd_multisms.sh - script for dividing sms for multiple receivers;
e)/usr/local/bin/smsd_scheduler.sh - main script's localization;
f)/usr/local/bin/scheduler/scheduler.sh - scheduler script localization;
g)/usr/local/bin/scheduler/timetable.csv - scheduler's settings file localization;
h)/usr/local/bin/scheduler/numbers.txt - scheduler.sh output file localization;
i)/usr/local/bin/scheduler/scheduler_errors.log - scheduler_errors log localization;

2)smsd.conf:

devices = Nokia
logfile = /var/log/smsd.log
loglevel = 5
regular_run = /usr/local/bin/smsd_scheduler.sh
regular_run_interval = 5
failed = /var/spool/sms/failed
sent = /var/spool/sms/sent
stats = /var/spool/sms/stats

[Nokia]
device = /dev/ttyACM0
pin = xxxx
'smsdconf' Syntax Highlight powered by GeSHi


3)scheduler.sh:

Our network management system generates sms alerts with proper filename according to event id:


Scheduler.sh script is set up for the number of '_' to localize phone number - You need to set it up according to Your environment:

SMS_FILES_NAME_SEP='_'
SMS_FILES_PHONE_NUM_POS=5
.
.
.
#get phone number form file name
find_number=$(echo $file | cut -d $SMS_FILES_NAME_SEP -f $SMS_FILES_PHONE_NUM_POS)


#!/bin/bash
#lock file
LOCK_FILE="/var/lock/sms_scheduler"

if [ -e $LOCK_FILE ]
then
 exit 0
else
 touch $LOCK_FILE
fi

#check args
if [ $# -eq 0 ]
then
echo "use $0 filename"
exit 0
fi

#check if file exist
if [ ! -e $1 ]
then
 echo "file $1 not exist"
 rm $LOCK_FILE
 exit 0
fi

#call spliter + WAIT ?
/usr/local/bin/smsd_multisms.sh /var/spool/sms/temp/*

#=========== read a  time table file ===================
FILE=$1
LINE_LENGHT=120
NUMBERS_FILE_OUT="/usr/local/bin/scheduler/numbers.txt"
HOUR_SEP=':'
TIME_SEP='-'
ITEM_SEP=';'

#empty file
if [ -e $NUMBERS_FILE_OUT ]; then
 rm -f $NUMBERS_FILE_OUT
fi

#get a day(1 = monday) and shift to start week ommit phone number and mail
TODAY=$(date +%u)
let TODAY+=2

#get a time and convert to minutes
TIME=$(expr $(date +%H) \* 60  + $(date +%M))
#echo "Time now: $TIME"

#process a time table file
cat $FILE | while read line
do

 #find time rande for today
 timeRange=$(echo $line | cut -d \; -f $TODAY)

 if [ $timeRange = "24h" ]; then

    echo $(echo $line | cut -d $ITEM_SEP -f 1 ) >> $NUMBERS_FILE_OUT

 elif [ $timeRange = "no" ]; then
        echo ""

 else

    #get start time from give day
    startHour=$(echo $timeRange | cut -d $HOUR_SEP -f1)
    startMinute=$(echo $timeRange | cut -d $HOUR_SEP -f2 | cut -d $TIME_SEP -f 1)
    startTime=$( expr $startHour \* 60 + $startMinute )
#    echo "Start time si: $startTime"

    #get stop time for give day
    stopHour=$(echo $timeRange | cut -d $TIME_SEP -f2 | cut -d $HOUR_SEP -f 1)
    stopMinute=$(echo $timeRange | cut -d $TIME_SEP -f2 | cut -d $HOUR_SEP -f2 )
    stopTime=$( expr $stopHour \* 60 + $stopMinute )
#   echo "Stop hour is : $stopTime"

    if [ $TIME -ge $startTime ] && [ $TIME -le $stopTime ]; then
      echo $(echo $line | cut -d $ITEM_SEP -f 1 ) >> $NUMBERS_FILE_OUT
    fi

 fi

done

#================== preocessing sms files =========================

#dir with sms to be send before filtering
SMS_FILES_DIR_IN="/var/spool/sms/scheduler"
SMS_FILES_DIR_OUT="/var/spool/sms/outgoing"
SMS_FILES_NAME_SEP='_'
SMS_FILES_PHONE_NUM_POS=5

#number which should be send in loop
cat $NUMBERS_FILE_OUT | while read number
do

 #sms files name
 ls $SMS_FILES_DIR_IN | while read file
 do

   #get phone number form file name
   find_number=$(echo $file | cut -d $SMS_FILES_NAME_SEP -f $SMS_FILES_PHONE_NUM_POS)

   if [ "$number" = "$find_number" ]; then
     mv -f $SMS_FILES_DIR_IN/$file $SMS_FILES_DIR_OUT
   fi

 done
done

rm $LOCK_FILE
 
'bash' Syntax Highlight powered by GeSHi


4)smsd_multisms.sh:

#!/bin/bash

# Sample script to allow multiple recipients in one message file - author Keke

temp=`ls /var/spool/sms/temp | wc -l`

if [[ $temp = 0 ]]
then
        exit 0
fi
recipients=`formail -zx "To:" < "$1"`
ECHO=echo
messagebody=`sed -e '1,/^$/ d' < "$1"`

  for recipient in $recipients
  do
    file="$1_$recipient"
    $ECHO "To: $recipient" > $file
    $ECHO "" >> $file
    $ECHO "$messagebody" >> $file
    mv $file /var/spool/sms/scheduler/
  done

  # Remove processed file:
  rm $1

exit 0
'bash' Syntax Highlight powered by GeSHi


5)smsd_scheduler.sh:

#! /bin/sh
HOME="/usr/local/bin/scheduler"
temp=`ls /var/spool/sms/temp/ | wc -l`
scheduler=`ls /var/spool/sms/scheduler/ | wc -l`

if [[ $temp = 0 && $scheduler = 0 ]]
then
        exit 0
fi
$HOME/scheduler.sh $HOME/timetable.csv >> $HOME/scheduler_errors.log 2>&1
'bash' Syntax Highlight powered by GeSHi


6)timetable.csv:

Settings for scheduler - You can modify these with few limitations:
-seven columns are days of week (Mon to Sun hh:mm format) - after the last one there needs to be a semicolon
-first hour need to be lower than second (I didn't wrote this :mrgreen: )
-number typing style needs to be the same as the one from sms format - check below SMS sample
-to disable sms notification put "no" in a proper column
-mail label for easy receiver's recognition


7)SMS sample:



Once more I would like to thank Keke for his support in this project - You made many admin's lives much more comfortable now ;)

Login and Post Reply

Page:  1

SMSTools3 Community » Feature requests Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.