I am trying to write a script that takes an array of server names and pings their spamd to make sure that it is still alive.

$t = new Net::Telnet(Prompt=>'//', Port=> 783, output_log=>"out_log.txt", input_log=>"in_log.txt", errmode=>"return");

for $server (@server_list) {

$t -> open($server);

$msg = $t -> errmsg;

if($msg ne "") {

print("ERROR: $msg\n");

} else {

$t->cmd(String=>"PING SPAMC/1.0");

$line = $t->getline();

}

$t -> close();

if($line =~ /PONG/) {

push(@goodservers, $server);

}else {

push(@badservers, $server);

}

$line="";

}

Is this a stable solution to my problem? Has anyone done anything like this and been successful?

Thanks,
TDM


Reply via email to