Perl script to fiddle emails

garbled

New member
This is a copy of the perl script I use to fiddle the apex emails down to a size that fits in a single SMS. I got really sick of getting 9 texts from my apex every time the temp got a little high, so now it does it in just one. Don't ask me how to make this work on a windows box, I have no idea. If you run unix/linux, set it in a .forward like so:

"|/usr/local/bin/reefmail.pl 9999999999@txt.att.net"

Basically, it just gives you the body of the alert, but lops off the big list of all sensor values at the end. It's nothing special, but, might be useful to someone.

Code:
#!/usr/pkg/bin/perl

$mailgood = 0;
$varline = 0;
$firstblank = 0;
$i = 0;
while (<STDIN>) {
        $mailgood = 1 if (/^Received: from neptunesys.com/);
        $firstblank = 1 if (/^$/ && !$firstblank);
        $varline = 1 if (/^ VarSpd1_I1/);

        if ($firstblank && !$varline) {
                $data[$i] = $_;
                $i++;
        }
}

if (!$mailgood) {
        exit 1;
}

open(MAIL, "|/usr/bin/mail -s 'Reef Alert' $ARGV[0] -f apex");
print MAIL @data;
close(MAIL);
exit(0);
 
Windows users can install ActiveState to get full Perl functionality. Creative way to reduce the email notifications. I turned it off for the same reason - 9 SMS messages was too much. Thanks for sharing.
 
Back
Top