Skip to content

Instantly share code, notes, and snippets.

@yuya-takeyama
Created October 17, 2010 09:47
Show Gist options
  • Save yuya-takeyama/630700 to your computer and use it in GitHub Desktop.
Save yuya-takeyama/630700 to your computer and use it in GitHub Desktop.
Script updates IP address of Dynamic DNS hosted on DDO.jp.
47 18 * * * perl /path/to/ddoupdate.pl your_sub_domain your_password >> /path/to/logfile
use strict;
use warnings;
use LWP::UserAgent;
use Time::Piece ();
my $ua = new LWP::UserAgent;
$ua->agent("ddoupdate.pl/0.0.1");
my ($domain, $password) = @ARGV;
my $url = "http://free.ddo.jp/dnsupdate.php?dn=$domain&pw=$password";
my $request = new HTTP::Request GET => $url;
my $response = $ua->request($request);
my $time = Time::Piece::localtime();
my $ymd = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
$time->year, $time->mon, $time->mday,
$time->hour, $time->minute, $time->sec);
my $status = $response->is_success &&
$response->content =~ /SUCCESS/ ? "OK" : "NG";
print "$ymd\t$status\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment