--- sms.alert 2003/02/06 12:12:36 1.4 +++ sms.alert 2003/02/21 10:36:01 1.7 @@ -28,7 +28,7 @@ # where 123456 is phone number (with country prefix, but without +) and # name is alias used like: # -# sms.alter -f dobrica +# sms.alert -f dobrica # # in mon.cf @@ -38,7 +38,7 @@ use strict; my %opt; use Getopt::Std; -getopts ("S:s:g:h:t:l:uf"); +getopts ("S:s:g:h:t:l:uf", \%opt); # read addressbook my %name2phone; @@ -71,19 +71,24 @@ my $sms = "From: mon\n"; $sms .= "Flash: yes\n" if $opt{f}; -$sms .= "\n$ALERT $opt{g}/$opt{s} $summary ($wday $mon $day $tm)\n"; +$sms .= "\n$ALERT"; +$sms .= " $opt{g}/$opt{s}" if ($opt{g} && $opt{s}); +$sms .= " $summary ($wday $mon $day $tm)\n"; # add next alter time $sms .= "Secs until next alert: $opt{l}\n" if $opt{l}; # add rest of text $sms .= join("\n",@MSG) if $opt{x}; +my $suffix = 0; + foreach my $to (@ARGV) { - if (open(SMS, "> $sms_outgoing/mon$$")) { + if (open(SMS, "> $sms_outgoing/mon-$$-$suffix")) { my $phone = $to; $phone = $name2phone{lc($to)} if ($name2phone{lc($to)}); die "$phone is not phone number! " if ($phone !~ m/^\d+$/); print SMS "To: $phone\n$sms"; close SMS; + $suffix++; } else { die "could not open sms file in '$sms_outgoing': $!"; }