File: //scripts.20110531.215904.25158/icontact
#!/usr/bin/perl
# cpanel - icontact Copyright(c) 2010 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
BEGIN { unshift @INC, '/usr/local/cpanel'; }
use strict;
use Storable;
use Getopt::Long;
use Cpanel::iContact qw( );
exit if (! defined $ARGV[0]);
my %msgdata = -f $ARGV[0] ? getparamsfromfile($ARGV[0]) : getparamsfromcli();
Cpanel::iContact::icontact(%msgdata);
sub getparamsfromfile {
my $file = shift;
my $msg_ref;
eval {
$msg_ref = retrieve($file);
};
if (defined $msg_ref && ref $msg_ref eq 'HASH') {
unlink $file;
return %{ $msg_ref };
} else {
warn "Unable to retrieve message hash from file $file";
exit;
}
}
sub getparamsfromcli {
my %msg_hash = ( 'application' => q{Info},
'level' => 3,
'subject' => q{},
'message' => q{},
'msgtype' => q{},
);
GetOptions('define=s' => \%msg_hash);
return %msg_hash;
}