[ale] Perl Equality
Robert Coggins
ALE at CogginsNet.com
Mon Oct 27 08:12:46 EST 2003
Hey all...
I have this script I wrote in cron to run every hour. Most of the time
the it works like I want it to. Although there are some times that it
will send me an email but everything looks like it is equal. Do any of
you have a suggestion as to why this is howing as eqal? Thanks for the
help!
-Rob
# Programmed by: Robert Coggins.
# This program is to check the external IP address of my system.
# If the IP is the same do nothing.
# If the IP is different email it and store new IP in a file
#!/usr/bin/perl
use LWP::Simple;
$WORK_PATH='/path/to/external_ip';
$EMAIL_ADD='anemail at address.com';
$EMAIL_FROM='from at address.com';
$EMAIL_REPLY='from at address.com';
$EMAIL_SUBJ='This is the current IP!';
$EMAIL_MESG='This is the current ip: ';
$file_cur = get('http://checkip.dyndns.org');
$file_cur =~ tr#a-zA-Z< >\t\n/:=##d;
open(infile, "< $WORK_PATH/theip");
$file_old = <infile>;
$file_old =~ tr#a-zA-Z< >\t\n/:=##d;
close(infile);
print $file_cur;
print $file_old;
if($file_cur eq $file_old){
print "The ips are the same.\n";
}
else{
open(outfile, "> $WORK_PATH/theip");
print outfile $file_cur;
close(outfile);
open(SENDMAIL, "| /usr/sbin/sendmail -t -n") || die "Unable to open
sendmail";
print SENDMAIL "From: $EMAIL_FROM\n";
print SENDMAIL "To: $EMAIL_ADD\n";
print SENDMAIL "Reply-To: $EMAIL_REPLY\n";
print SENDMAIL "Subject: $EMAIL_SUBJ\n\n";
print SENDMAIL "$EMAIL_MESG $file_cur";
close(MAIL);
}
More information about the Ale
mailing list