Re: Open files and looking a word



On 8/31/07, Rodrigo Tavares <digolinopage@xxxxxxxxxxxx> wrote:
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";
}


Snip if you have an array of hosts then you should say

for my $host (@host) {
system "ping -c 4 $hosts >> hosts.txt";
}

instead, but really, you shouldn't even be using system:

#!/usr/bin/perl

use strict;
use warnings;

use Net::Ping;

my @hosts = @ARGV;
my $pinger = Net::Ping->new;

for my $host (@host) {
print "$host is down\n" unless $pinger->ping($host);
}
.



Relevant Pages

  • Re: Forensic Survey, help needed for a research/training program
    ... forensics or network based forensics? ... Host based forensic questions ... system rather than shutting it down or disconnecting it from the network? ... Given a log file for an incident, what can you look for to determine ...
    (Security-Basics)
  • Forensic Survey, help needed for a research/training program
    ... forensics or network based forensics? ... Host based forensic questions ... system rather than shutting it down or disconnecting it from the network? ... Given a log file for an incident, what can you look for to determine ...
    (Security-Basics)
  • Re: Default Sender
    ... Yes, could you delete the log file you currently have, then send a message ... >> 2004.12.06 21:59:15 Mizzou: Synch operation completed ... >>>>I do not need to authenticate and I have SP 1 installed. ...
    (microsoft.public.outlook.general)
  • Re: FP2000 and SP2
    ... However has the host actually looked at the server's log file for the issue? ... Also if the host is testing within their network, it is a invalid test, as it is not the same as a ... FrontPage Resources, WebCircle, MS KB Quick Links, etc. ...
    (microsoft.public.frontpage.client)
  • Re: ISA Server 2004 Log Manipulation
    ... which when exploited will enable a malicious user to manipulate ... the Destination Host parameter of the log file. ... or record separator characters in the log file)? ...
    (Bugtraq)