#!C:\Perl\bin\perl.exe
# Take output of Data Protector Session and send in an email
use warnings;
use strict;
use MIME::Lite;
use Getopt::Std;
my $file = "output_" . time() . ".txt";
open (IN, "omnidb -session -latest -detail|") or die "$!";
open(OUT, ">$file") or die "$!";
while (<IN>)
{
print OUT $_ ;
}
my $SMTP_SERVER = 'spec-mail.spectacor.comcast-spectacor.com';
my $DEFAULT_SENDER = 'ekrengel@comcast-spectacor.com';
my $DEFAULT_RECIPIENT = 'ekrengel@comcast-spectacor.com';
MIME::Lite->send('smtp', $SMTP_SERVER, Timeout=>60);
my (%o, $msg);
# process options
getopts('hf:t:s:', \%o);
$o{f} ||= $DEFAULT_SENDER;
$o{t} ||= $DEFAULT_RECIPIENT;
$o{s} ||= 'Your binary file, sir';
if ($o{h} or !@ARGV) {
die "usage:\n\t$0 [-h] [-f from] [-t to] [-s subject] file ...\n";
}
# construct and send email
$msg = new MIME::Lite(
From => $o{f},
To => $o{t},
Subject => $o{s},
Data => "Test",
Type => "multipart/mixed",
);
while (@ARGV) {
$msg->attach('Type' => 'application/octet-stream',
'Encoding' => 'base64',
'Path' => shift @ARGV); #<---HERE MAYBE?
}
$msg->send( );