Router Test

Sometimes it is handy to check to see if you’ve got connectivity through an ethernet interface, especially a wireless one.  This Perl program does a ping to see if the router answers and tells HCA the results.

use Net::Ping;
my $p = Net::Ping->new;
my $outfile = “perl-flags.txt”;
my $outline = “”;
open OUTPUT, “> $outfile” or die “Output file open error: $!”;

if ($p->ping(“192.168.2.1”)){
$outline = “router2conn=yes”
}
else{
$outline = “router2conn=no”
}
print OUTPUT $outline;
close OUTPUT;

As In Various and Sundry