sub runCommands { $a=Net::Rsh->new(); $host="$ip"; $local_user="root"; $remote_user="root"; $cmd="/home/admin/master/pushout/scripts/$program"; if ( defined($a) ) { $status = $a->rsh($host,$local_user,$remote_user,$cmd); if ( ! defined($status) ) { $msg = $rsh->errmsg; print "\t$msg\n"; print LOG "\t$ip\t$msg\n"; $rsh->close; } else { print PING "$ip $hostname\n"; # Run the program $a->rsh($host,$local_user,$remote_user,$cmd); sleep 1; } } else { print "\t$ip\tConnection refused.\n"; print LOG "\t$ip\tConnection refused.\n"; } }