Author |
Post |
|
#1 Mon Dec 13, 2010 08:58, 169 months ago.
|
Member
Registered: Dec 2010
Location: Poland
|
Hello, I was looking for this feature, but I didn't find it. I'm using SMSTools in our NMS to send sms alerts. Everything works great, but I can't send the same alert to many persons - at this moment I'm making new sms for every one..The question is:what should the message form look like to be send to many numbers?Below there are some examples which I tried, but without success:
1) To: 48600700800; 48600700801
SMSmessage 2) To: 48600700800 To: 48600700801
SMSmessage
3) To: 48600700800 48600700801
SMSmessage
Thanks in advance for any help in this topic.
Peter
|
|
#2 Mon Dec 13, 2010 11:14, 169 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
For smsd every SMS is a single file. This is because sending to some numbers may fail, delivery timestamps are stored to files, etc... You can use checkhandler to check "To:" field(s) and create multiple files if necessary. Here is an example: Multiple recipients in single SMS file.
|
|
#3 Mon Dec 13, 2010 11:39, 169 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
I just edited the sample. It now allows multiple numbers in single To: field, and also multiple To: fields. Semicolon also works, but do not use it.
|
|
#4 Mon Dec 13, 2010 12:49, 169 months ago.
|
Member
Registered: Dec 2010
Location: Poland
Topic owner
|
Sorry for bothering You about something that was already solved before Keke :] But I'm having some problems with using this script: My smsd.conf: Your sample script /etc/multisms.conf: #!/bin/bash
# Sample script to allow multiple recipients in one message file. # Define this script as a checkhandler.
outgoing="/var/spool/sms/outgoing"
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 fi
exit 0 'bash' Syntax Highlight powered by GeSHi Result when I'm trying to restart smsd: My smsd version:
|
|
#5 Mon Dec 13, 2010 13:00, 169 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
moss2k10 wrote chmod 755 /etc/multisms.conf
|
|
#6 Mon Dec 13, 2010 13:27, 169 months ago.
|
Member
Registered: Dec 2010
Location: Poland
Topic owner
|
Of course Keke - I've noticed this after I post my reply One more thing: your script generates random temp file names: Is there a chance to stay with original names with only tiny changes for example: originalnameofsms_1,2,3? In our case the name of the sms is the name of event and it's quite needed for troubleshooting.. Thanks, Peter
|
|
#7 Mon Dec 13, 2010 14:15, 169 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
The script can do anything what is required... Comment out the line containing mktemp and add those three lines. This will keep the original name and add _1, _2 and so on: do #file=`mktemp $outgoing/send_XXXXXX` [ -z $nr ] && nr=1 file="$1_$nr" nr=$(($nr + 1)) 'bash' Syntax Highlight powered by GeSHi Perhaps a phone number also can be used. /var/spool/sms/outgoing/eventname_phonenumber: do #file=`mktemp $outgoing/send_XXXXXX` file="$1_$recipient" 'bash' Syntax Highlight powered by GeSHi Also note that you can use your own headers in the SMS file, if they do not override existing headers in smsd ( fileformat). This will add a "Event:" header to the file and later all details can be read from file: tmp=$(readlink -f $1) event=${tmp##*/}
for recipient in $recipients do #file=`mktemp $outgoing/send_XXXXXX` [ -z $nr ] && nr=1 file="$1_$nr" nr=$(($nr + 1))
$ECHO "To: $recipient" > $file if [ "x$headers" != "x" ]; then $ECHO "$headers" >> $file fi $ECHO "Event: $event" >> $file $ECHO "" >> $file $ECHO -n "$messagebody" >> $file done 'bash' Syntax Highlight powered by GeSHi
|
|
#8 Mon Dec 13, 2010 14:33, 169 months ago.
|
Member
Registered: Dec 2010
Location: Poland
Topic owner
|
This is exactly what I've been looking for - now our NMS alerts work epicly Big thanks for Your help Keke! Peter
|