perl script for logging external ip address and analysing changes from its logfile
This commit is contained in:
parent
c4d2aba012
commit
7aa21bd2fd
2 changed files with 27 additions and 0 deletions
6
externalIp.pl
Normal file
6
externalIp.pl
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
($ip=`wget -q -O - http://checkip.dyndns.org`)=~s/\n$//;
|
||||
$ip=~s/.*[^\d](\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[^\d].*/$1/;
|
||||
($date=`date`)=~s/\n$//;
|
||||
print "$date\n$ip\n";
|
21
ipchanges.pl
Normal file
21
ipchanges.pl
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
my $file = "/home/lookshe/myips.txt";
|
||||
|
||||
open(FILE, $file) || die("unable to open $file!");
|
||||
my @lines = <FILE>;
|
||||
close(FILE);
|
||||
|
||||
for ($i = 1; $i <= $#lines-2; $i+=2)
|
||||
{
|
||||
my $ip = $lines[$i];
|
||||
chomp($ip);
|
||||
my $nextip = $lines[$i+2];
|
||||
chomp($nextip);
|
||||
if ($ip !~ m/^$nextip$/)
|
||||
{
|
||||
my $time = $lines[$i+1];
|
||||
chomp($time);
|
||||
print "$time: $ip -> $nextip\n";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue