Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gav (2710)

gav
  (email not shown publicly)
http://www.estey.com/
AOL IM: flufflegavin (Add Buddy, Send Message)

Hacker in NYC.

Journal of gav (2710)

Sunday February 01, 2004
03:18 PM

Getting domain expiry dates

[ #17140 ]

This little script will send you an email with the expiry dates for a list of domains. It's a nice thing to run as a cronjob once a month or so.

#!/usr/bin/perl -w
use Net::Domain::ExpireDate;
use Time::Piece;
use Mail::Sendmail;
use Getopt::Long;
$|++;
GetOptions(debug => \my $debug);
my %domain;
while (<DATA>) {
    chomp;
    my $date = expire_date($_) or die "Can't get expiry date for '$_'";
    $debug and printf "%s expires on %s\n", $_, $date;
    $domain{$date->epoch} = $_;
}
my $msg = "Expiry dates for all hosted domains\n\n";
foreach my $date (sort { $a <=> $b } keys %domain) {
    $msg .= sprintf "%s: %s\n",
        Time::Piece->new($date)->strftime("%d %b %Y"), $domain{$date};
}
sendmail(
    To      => 'you@example.com',
    From    => 'yourserver@example.com',
    Subject => 'Domain expiry report',
    Message => $msg
) or die "Unable to send mail: $Mail::Sendmail::error";
exit;
__DATA__
# domains go here, one per line

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.