Skip to content

Instantly share code, notes, and snippets.

@hpcx82
Created December 2, 2012 01:15
Show Gist options
  • Save hpcx82/4186334 to your computer and use it in GitHub Desktop.
Save hpcx82/4186334 to your computer and use it in GitHub Desktop.
monitor a domain, send a mail if it is no longer "pendingDelete"
use strict;
my $targetPage = $ARGV[0]; #http://www.kingtoo.com/reg/whois.asp?domain=douban.com
print $targetPage . "\n";
my @page = `curl $targetPage | iconv -f gb2312 -t utf8`;
chomp @page;
my $domainStatus;
for my $line (@page)
{
if($line =~ /Status: (\w+)/)
{
$domainStatus = $1;
print $domainStatus;
print "\n";
}
}
if ($domainStatus eq "pendingDelete")
{
print "The domain is still in pending state\n";
}
else # as soon as the status is changed away from "pendingDelete", notify us!
{
my $message = "Hi, Baiyan:\n The domain: $targetPage is ready, please register ASAP\n";
my $sendmail = "echo '$message' | mail -s 'Urgent: Please register the domain!!!' baiyanhuang\@126.com";
#print $sendmail;
print "sending mail...\n";
print `$sendmail`;
}
@hpcx82
Copy link
Author

hpcx82 commented Dec 2, 2012

$ perl monitorweb.pl "http://www.kingtoo.com/reg/whois.asp?domain=douban.com"
http://www.kingtoo.com/reg/whois.asp?domain=douban.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 29598 100 29598 0 0 12139 0 0:00:02 0:00:02 --:--:-- 12768
ok
sending mail...

@hpcx82
Copy link
Author

hpcx82 commented Dec 2, 2012

对于非pendingDelete的域名,行为是不正确的,但是现在我只care那个域名。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment