#!/usr/bin/perl -w use LWP::UserAgent; my $l_hostname = shift @ARGV or die "Pass an IP or hostname, ya muppet\n"; my $l_port = shift @ARGV || 80; my $l_timeout =shift @ARGV || 5; my $ua = LWP::UserAgent->new; $ua->timeout($l_timeout); my $response = $ua->get('http://' . $l_hostname . ':' . $l_port . '/'); exit 0 if $response->is_success; # No response ... exit 1;
gregor@sauzee:~$ if $(./checkService.pl eck.local 22) ; then echo "alive" ; fi alive gregor@sauzee:~$
gregor@sauzee:~$ if ! $(./checkService.pl eck.local 23) ; then echo "FTP is pure deid man" ; fi FTP is pure deid man gregor@sauzee:~$