/[mon-modules]/sms.alert
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sms.alert

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by dpavlin, Fri Feb 14 14:52:02 2003 UTC revision 1.7 by dpavlin, Fri Feb 21 10:36:01 2003 UTC
# Line 28  Line 28 
28  # where 123456 is phone number (with country prefix, but without +) and  # where 123456 is phone number (with country prefix, but without +) and
29  # name is alias used like:  # name is alias used like:
30  #  #
31  # sms.alter -f dobrica  # sms.alert -f dobrica
32  #  #
33  # in mon.cf  # in mon.cf
34    
# Line 38  my $sms_addressbook = "/usr/local/etc/sm Line 38  my $sms_addressbook = "/usr/local/etc/sm
38  use strict;  use strict;
39  my %opt;  my %opt;
40  use Getopt::Std;  use Getopt::Std;
41  getopts ("S:s:g:h:t:l:uf");  getopts ("S:s:g:h:t:l:uf", \%opt);
42    
43  # read addressbook  # read addressbook
44  my %name2phone;  my %name2phone;
# Line 79  $sms .= "Secs until next alert: $opt{l}\ Line 79  $sms .= "Secs until next alert: $opt{l}\
79  # add rest of text  # add rest of text
80  $sms .= join("\n",@MSG) if $opt{x};  $sms .= join("\n",@MSG) if $opt{x};
81    
82    my $suffix = 0;
83    
84  foreach my $to (@ARGV) {  foreach my $to (@ARGV) {
85          if (open(SMS, "> $sms_outgoing/mon$$")) {          if (open(SMS, "> $sms_outgoing/mon-$$-$suffix")) {
86                  my $phone = $to;                  my $phone = $to;
87                  $phone = $name2phone{lc($to)} if ($name2phone{lc($to)});                  $phone = $name2phone{lc($to)} if ($name2phone{lc($to)});
88                  die "$phone is not phone number! " if ($phone !~ m/^\d+$/);                  die "$phone is not phone number! " if ($phone !~ m/^\d+$/);
89                  print SMS "To: $phone\n$sms";                  print SMS "To: $phone\n$sms";
90                  close SMS;                  close SMS;
91                    $suffix++;
92          } else {          } else {
93                  die "could not open sms file in '$sms_outgoing': $!";                  die "could not open sms file in '$sms_outgoing': $!";
94          }          }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.26