IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19143


Ignore:
Timestamp:
Aug 20, 2008, 3:56:55 PM (18 years ago)
Author:
jhoblitt
Message:

add --email option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/arclog/arclog.pl

    r19139 r19143  
    33use strict;
    44use warnings;
     5
    56use vars qw( $VERSION );
    67$VERSION = '0.01';
     
    1314use DateTime::Format::Strptime;
    1415use DBI;
    15 
    16 #use Getopt::Long qw( GetOptions :config auto_help auto_version );
     16use Email::Send;
     17
     18use Getopt::Long qw( GetOptions :config auto_help auto_version );
    1719use Pod::Usage qw( pod2usage );
    18 # accept no options
     20
     21my ($email);
     22
     23GetOptions(
     24    'email|s=s'    => \$email,
     25) || pod2usage( 2 );
     26
    1927pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    2028
     
    3442$dbh->do("CREATE TABLE IF NOT EXISTS log(record TEXT, PRIMARY KEY(record))")
    3543    or die "db error";
     44
     45my $errors;
     46my $output;
     47###
     48if (defined $email) {
     49    close(STDOUT);
     50    close(STDERR);
     51    open(STDOUT, '>', \$output) or die "Can't open STDOUT: $!";
     52    open(STDERR, '>', \$errors) or die "Can't open STDERR: $!";
     53}
    3654
    3755# HTTP authentication realm
     
    174192    use warnings;
    175193}
     194
     195my $message =<<END;
     196To: $email
     197From: jhoblitt\@ifa.hawaii.edu
     198Subject: output from arclog.pl
     199
     200$errors
     201$output
     202END
     203
     204my $sender = Email::Send->new({mailer => 'SMTP'});
     205$sender->mailer_args([Host => 'hale.ifa.hawaii.edu']);
     206$sender->send($message);
    176207
    177208
Note: See TracChangeset for help on using the changeset viewer.