Rodney Ray wrote:
> 
> Here is the deal. I want to use perl to ping a server and need to get the address from a flat file that has a fix file format. The field that I'm tring to get is the second column in the file. Any Perl experts that could help me get  this thing working on my box. The grep4=ntharg(entry,2,\":\");\ returns the the second field but I can't get ping to use the  the grep4.

fake_file.txt
-------------

server_name_1:192.168.0.10
server_name_2:192.168.0.12

ping_server.pl
--------------

#!/usr/bin/perl

$flag = "FALSE";
open(FH, "fake_file.txt");
while(<FH>)
{
    @serv_info = split(/:/,$_);
    @res = `ping -c2 $serv_info[1]`;
    # have to loop through all of what ping returns and check for a
failure
    foreach $snech (@res) {
      if ($snech =~ /100\% packet loss/) {
	$flag = "TRUE";
      }
    }
    if ($flag eq "TRUE")
    {
	# do something, like update resume and leave town
       `epage "$serv_info[0] is on fire\n"`;
     }
     $flag = "FALSE";
}


Or did I oversimplify?


Paul Rech

> 
> _______________________________________________
> tclug-list mailing list
> tclug-list at mn-linux.org
> https://mailman.mn-linux.org/mailman/listinfo/tclug-list