leostereo has asked for the wisdom of the Perl Monks concerning the following question:
and , line_process.pl is:#!/usr/bin/perl -w use strict; use File::Tail; my $file = File::Tail->new( name =>'/var/log/messages', interval => 1, maxinterval => 1, # resetafter=> 5, ); while (defined(my $line=$file->read)) { print $line; }
When I run them individually they work ok, but when I try to pipe them doing:#!/usr/bin/perl -w use strict; use Net::Ping; my $result; while (<>){ my $p = Net::Ping->new('icmp',3); if ($_ =~ /^(.*) dns02cor dhcpd: DHCPACK on ([0-9\.]+) + to ([[:xdigit:]:]+).* ([0-9\.]+)/) { for (my $i = 0; $i < 3; $i++){ print "attempt $i for $2 \n"; $result = $p->ping($2); if ($result){ print "############## +$2 is alive at attempt $i\n"; last; } $p->close(); } unless ($result){ print "*****$2 is dead*****\n +"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: pipe issue (linux)
by NetWallah (Canon) on May 05, 2016 at 20:33 UTC | |
|
Re: pipe issue (linux)
by haukex (Archbishop) on May 05, 2016 at 20:11 UTC | |
|
Re: pipe issue (linux) (buffering)
by tye (Sage) on May 06, 2016 at 20:00 UTC | |
|
Re: pipe issue (linux)
by james28909 (Deacon) on May 05, 2016 at 20:09 UTC | |
by haukex (Archbishop) on May 05, 2016 at 20:23 UTC |