#!/usr/bin/perl -w use strict; use Net::Ping; my $fetchmail = '/usr/local/bin/fetchmail'; my @fetchmail_args = ('-s', '-t', '60'); my $hostname = 'hostname'; # an external host my $timeout = 3; my $p = Net::Ping->new('udp', $timeout); if( $p->ping($hostname) ){ print "$hostname is alive.\n"; # exec($fetchmail, @fetchmail_args); }else{ print "$hostname is unreachable.\n"; }