Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b945202
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use strict; | ||
|
||
+{ | ||
debug => 1, | ||
username => "foo", | ||
password => "bar", | ||
mail_to => "baz", | ||
mail_from => "qux", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |