I have a working script but it produces some warnings. In the interest of cleaning it up and learning a little more about perl, could someone advise me what is causing the errors?
Here is the script:
[/color green]
Here are the errors:
Subroutine bits redefined at /System/Library/Perl/5.8.6/strict.pm line 11.
Subroutine import redefined at /System/Library/Perl/5.8.6/strict.pm line 27.
Subroutine unimport redefined at /System/Library/Perl/5.8.6/strict.pm line 32.
Thanks.
Here is the script:
Code:
#!/usr/bin/perl -w
use Strict;
use Net::POP3;
use Authen::Krb5;
use Authen::SASL 2.10;
use Getopt::Long;
use Pod::Usage;
my ($user,$pass,$host,$help,$man);
my $del=1;
GetOptions('user=s' => \$user,
'pass=s' => \$pass,
'host=s' => \$host,
'help' => \$help,
'delete!'=> \$del, # for debug purposes
'man' => \$man) or pod2usage(2);
my $USERNAME=$user;
my $SERVICE="pop";
my $PASSWORD=$pass;
my $SERVER=$host;
pod2usage(1) if $help;
pod2usage(-exitstatus => 0, -verbose => 2) if $man;
pod2usage(2) unless $user && $pass && $host;
my $ac=Authen::Krb5::init_context();
defined $ac or die "Fatal: Unable to establish Kerberos context\n";
my $clientp=Authen::Krb5::parse_name($USERNAME);
my $serverp=Authen::Krb5::sname_to_principal($SERVER,$SERVICE,KRB5_NT_SRV_HST);
my $cc=Authen::Krb5::cc_default();
$cc->initialize($clientp);
if (Authen::Krb5::get_in_tkt_with_password($clientp,$serverp,$PASSWORD,$cc)) {
my $sasl=new Authen::SASL(mechanism=> "GSSAPI SASL");
my $pop=Net::POP3->new($SERVER)
or die "Unable to connect to mail server: ",$!,"\n";
if ($pop->auth($sasl)) {
my $messages=$pop->list()
or die "Unable to get messages: ",$!,"\n";
print "$user\@$host: ",scalar (keys (%$messages))," messages\n";
foreach $num (keys (%$messages))
{
$pop->delete($num) if $del;
}
$pop->quit;
}
else {
print "Authentication failed: ",$!,"\n";
}
}
exit 0;
Here are the errors:
Subroutine bits redefined at /System/Library/Perl/5.8.6/strict.pm line 11.
Subroutine import redefined at /System/Library/Perl/5.8.6/strict.pm line 27.
Subroutine unimport redefined at /System/Library/Perl/5.8.6/strict.pm line 32.
Thanks.