[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bigsister-general] Paging and SMS script



Tino and other interested BigSister users,

- A quick disclaimer: use this at your own risk. It works OK for us. Your Mileage May Vary. -

We use qpage because it can dial a modem (out-of-band) to send messages to us. There are other SNPP programs out there, we just happened to use this one. We're on qpage v3.3. Note that qpage is not really an SMS program, but a program which uses TAP. Many SMS services have TAP gateways. There are companies which offer universal TAP gateways into pager and SMS systems (Unimobile is one of these companies). The Modem is attached to the same BigSister machine. There is no network stuff going on with qpage in this circumstance, however qpage does support this. I'm in the United States, so I don't know what TAP gateways exist apart from here. You may have to do a little digging with your telephone service provider in order to accomplish this.

Qpage's website presently appears to be down (www.qpage.org). A Debian GNU/Linux package exists here: http://packages.debian.org/stable/net/qpage

Here's a sample of /etc/qpage.cf:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
suppressed

queuedir=/var/spool/qpage

identtimeout=3
snpptimeout=60
synchronous=true

# Our modem
modem=hayes
    device=/dev/ttyS1
    initcmd=atz,l0m0
    #initcmd=ATE1,V1,&A0&K0&M0
    initcmd=atz,l0m0
    #initcmd=ATE1,V1,&A0&K0&M0
    #initcmd=AT&H1&I0&M0
    #initcmd=AT&N6
    # dial command for internal office line
    #dialcmd=atdt9,
    # dial command for external line
     dialcmd=atdt

service=verizon-cell
    device=hayes
    phone=18668230501
    parity=even
    maxmsgsize=140
    maxpages=1
    baudrate=2400

service=skytel2way
    device=hayes
    phone=18006792778
    baudrate=2400
    parity=even
    maxmsgsize=240
    maxpages=2

service=tmobile
    device=hayes
    phone=14253964560
    parity=even
    maxmsgsize=160
    maxpages=1
    baudrate=9600

# --------------------------------------------------------------------------
# PAGERS
# --------------------------------------------------------------------------

# John Doe's Verizon CDMA mobile phone
pager=doej
    pagerid=2125551234
    service=verizon-cell

# Bob Smith's Skytel 2-way pager
pager=smithb
   pagerid=2021259876
   service=skytel2way

# System Administrators
group=sysadmins
    member=doej
    member=smithb

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++






Here's some of the stuff in adm/bb_eventgenerator specific to the wrapper script:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
...
# The script called "qpagewrapper" lives in ~bs/bin.
PAGER{$mail eq "qp-doej"} pager=qpagewrapper mail=doej
PAGER{$mail eq "qp-smithb"} pager=qpagewrapper mail=smithb
PAGER{$mail eq "qp-sysadmins"} pager=qpagewrapper mail=sysadmins
...
@IntraRTR.dns;@IntraRTR.http{daytime 18:01-07:59 or weekday Sat,Sun} \
prio=80 delay=30 down=red up=green repeat=240 \
suppressed,qp-sysadmins,suppressed \
check="$host.conn"
...
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




Here is the Perl wrapper (qpagewrapper) that I used to clean up the text before delivering to Qpage:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#!/usr/bin/perl -w

use Time::localtime;
use Logfile::Rotate;

# Copyright 2004 Louis Dreyfus Corporation
# This code is free for use and modification provided you adhere to the GPL
# GNU Public License (to see it, go to http://www.gnu.org/licenses/gpl.txt )


# 2004-12-22
# A bug was discovered: the debug file is removed from /tmp upon a restart
# The code fails if the file does not exist. This needs to be fixed regardless
# of the position in the filesystem


# Code to mind the debuglog size and rotation
$debuglog = "/tmp/qpagewrapper.debug.file";
($size) = (stat("$debuglog"))[7];
$maxlogsize = 1048576;
##


$logfile = new Logfile::Rotate(
        File    => "$debuglog",
        Count   => 4
        );
if ($size > $maxlogsize) {
        $logfile->rotate();
        undef $logfile;
}

# Append to the debug log
open(DEBUG,">>$debuglog");
################## End of DEBUGLOG code ##################################
# $input is the text message from big sister.
$input = <STDIN>;

################# Timestamp code #####################################
$time = time();
$tm = localtime($time);
printf DEBUG ("Dateline: %02d:%02d:%02d-%04d/%02d/%02d\n",
        $tm->hour, $tm->min, $tm->sec, $tm->year+1900,
        $tm->mon+1, $tm->mday);
print DEBUG "Args: @ARGV \n";
print DEBUG "input: \n";
print DEBUG $input, "\n";

##############################
## Cleanup the message text ##
##############################
# delete leading 'Subject: ' strings
$input =~ s/^Subject: //;

# Replace all |> with |
$input =~ s/\|\>/\|/g;

# The strings &red, &green, or &yellow are rather annoying. Delete them
$input =~ s/\&red//g;
$input =~ s/\&green//g;
$input =~ s/\&yellow//g;

# Remove trailing pipe characters
$input =~ s/\|$//;

print DEBUG "shortened:\n";
# Keep the pages to one page. Pagers and cell phones usually accept up to about
# 120-160 characters per message
#   keep in mind that qpage prepends "bs:" to the front of the message"
# Verizon changed something so now I can get about 100 characters. J. Russell 2004-06-15
$shortened=substr($input,0,117);
#$shortened=substr($input,0,100);
print DEBUG $shortened, "\n";
print DEBUG "---------------- \n";
close(DEBUG);

# to-fix: this system call doesn't deal with errors from qpage very well
# thankfully, it works well enough.
system("qpage -P @ARGV '$shortened'");

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




Best Regards,

Jim
Systems Admin. - Louis Dreyfus Corporation

Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.