#!/usr/bin/perl -w use strict; use Net::SSH qw(ssh); use constant USER => 'root'; use constant CMD => '/usr/local/scripts/temp.sh'; for my $host (qw( 192.168.15.2 192.168.16.2 192.168.17.2 192.168.18.2 )) { (ssh(USER . '@' . $host, CMD) != 256) and last; warn "No response from $host\n"; }