Open files and looking a word



Hello,

I'm doing a script, it run a ping in many computers
and create a log file.

I need search in log file the word "Destination Host
Unreachable". So, I have to take below line. After
using regular expressions taking ferrari.lab and print
"The host is down !".

example:
PING ferrari.lab (192.168.1.152) 56(84) bytes of data.
From goal.lab (192.168.1.7) icmp_seq=2 Destination
Host Unreachable

How I do it ?

Begin of script, wih array with host names:

print "Testing the computers....\n";
for (my $i=0 ; $i < 5 ; $i++)
{
system "ping -c 4 $hosts[$i] >> hosts.txt";
}


Best regards,

Faria


Flickr agora em português. Você clica, todo mundo vê.
http://www.flickr.com.br/
.



Relevant Pages

  • Re: Help with Expect
    ... > I need some help with an expect script I'm trying to write. ... If the host responds to pings telnet into it. ... You can ping a host and test whether it was successful from a shell ...
    (freebsd-questions)
  • Re: find local computers
    ... >>ping cannot resolve a name, it can resolve a name to IP prior to sending ... > have a way to find all those boxes, ip addr and host name. ... > This script could actually be used to put together canonical hosts files, ... I beleive you need a reverse DNS lookup ...
    (RedHat)
  • Re: Help with Expect Script
    ... I want the script to ping the ... > host to see if it's alive first before it telnets into it. ... I already know how to telnet to the host, ...
    (freebsd-questions)
  • help with this script
    ... i've this script that take ip's from text file do ping to every ip and write ... the results into ping.csv then change the local admin password to each ip. ... If Not FSO.FileExistsThen 'If log file does not exist ... 'Ping the computers ...
    (microsoft.public.windows.server.scripting)
  • Help with Expect Script
    ... I want the script to ping the ... host to see if it's alive first before it telnets into it. ... I already know how to telnet to the host, ...
    (freebsd-questions)