#!/usr/bin/perl -w use IO::SOCKET::INET; ##CALL IP FROM SYSTEM## $ipconfig=`ipconfig`; $ipconfig=~/(.*IP.*\: )(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/; ##CHECK IF CURRENT IP IS SAME AS LAST IP## open(LAST,">last_ip_info.txt") or die "couldn't open last status file. reason:$!\n"; @last=; close(LAST); #if($last[0]eq$2) #{ # print 'current IP is the same as last IP'; #} #else #{ &mail_ip($2); #} ##PRINT OUT CURRENT IP## #print "IP\:"."$2".":IP\n"; open(LAST,">last_ip_info.txt") or die "couldn'topen last status file$!\n"; print LAST "$2\n"; close(LAST); ################# ###SUBROUTINES### ################# sub mail_ip { my$ip=@_[0]; $smtpaddr='jman.g3d.com'; $mail_to='jrock@jman.g3d.com'; $mail_from='nehalspc@exario.net'; $hostname='nehal'; $sock = new IO::Socket::INET (PeerAddr => "$smtpaddr", PeerPort => 25, Proto => 'tcp', ); die "Socket could not be created. Reason: $!\n" unless $sock; while($line=<$sock>) { print "$line\n"; if($line=~/220/) { last; } } print $sock "helo $hostname\n"; print "helo $hostname\n"; while($line=<$sock>) { print "$line\n"; if($line=~/250/) { last; } } print $sock "MAIL FROM: $mail_from <$mail_from>\n"; print "MAIL FROM: $mail_from <$mail_from>\n"; while($line=<$sock>) { print "$line\n"; if($line=~/250/) { last; } } print $sock "RCPT FROM: $mail_to <$mail_to>\n"; print "RCPT FROM: $mail_to <$mail_to>\n"; while($line=<$sock>) { print "$line\n"; if($line=~/250/) { last; } } print $sock "DATA\n\n"; print "DATA\n\n"; while($line=<$sock>) { print "$line\n"; if($line=~/354/) { last; } } print $sock "\r\n.\r\n"; print ".\n"; while($line=<$sock>) { print "$line\n"; if($line=~/250/) { last; } } print $sock "QUIT\n"; print "QUIT\n"; while($line=<$sock>) { print "$line\n"; if($line=~/221/) { last; } } close ($sock); }