Skip to content

Commit

Permalink
*.dyndns.org切らしてしまってご迷惑おかけしますた。
Browse files Browse the repository at this point in the history
  • Loading branch information
bokutin committed Dec 2, 2009
0 parents commit b945202
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
9 changes: 9 additions & 0 deletions etc/login_dyndns_org.pl
@@ -0,0 +1,9 @@
use strict;

+{
debug => 1,
username => "foo",
password => "bar",
mail_to => "baz",
mail_from => "qux",
};
47 changes: 47 additions & 0 deletions script/login_dyndns_org.pl
@@ -0,0 +1,47 @@
#!/usr/bin/env perl

use strict;
use warnings;
use Config::JFDI;
use FindBin;
use MIME::Lite;
use Try::Tiny;
use WWW::Mechanize;

my $CONFIG = Config::JFDI->new(name => "login_dyndns_org", path => "$FindBin::Bin/../etc");
my $DEBUG = $CONFIG->config->{debug};

try {
my $top = "http://www.dyndns.com/";
my $mech = WWW::Mechanize->new();
$mech->get( $top );
$mech->submit_form(
fields => {
username => $CONFIG->config->{username},
password => $CONFIG->config->{password},
},
);
die sprintf("login failed. %s", $mech->content) unless $mech->content =~ m/Logged In User/i;
}
catch {
my $msg = MIME::Lite->new(
From => $CONFIG->config->{mail_from},
To => $CONFIG->config->{mail_to},
Subject => '[login_dyndns_org.pl] exception error',
Data => $_ || "unknow error",
);
$msg->send;
exit 1;
};

if ($DEBUG) {
my $msg = MIME::Lite->new(
From => $CONFIG->config->{mail_from},
To => $CONFIG->config->{mail_to},
Subject => '[login_dyndns_org.pl] login succeeded',
Data => 'login succeeded',
);
$msg->send;
}

exit 0;

0 comments on commit b945202

Please sign in to comment.