#!/usr/bin/perl use strict; my $lastip; if (open IP, '; chomp $lastip; close IP } else { print "**keepalive.pl** File 'lastip.dat' cannot be opened to read: $!" } if (`netstat -i` =~ /eth1.*?inet addr:(\d+\.\d+\.\d+\.\d+)/s) { if ($1 ne $lastip) { print "**keepalive.pl**\n\n".`/etc/init.d/ntpd restart`; if (open IP, '>/home/phil/usr/cron/lastip.dat') { print IP "$1\n"; close IP } else { print "**keepalive.pl** File 'lastip.dat' cannot be opened to write: $!" } } } else { print "**keepalive.pl**\n\n".`/etc/init.d/network restart` }