hmb104 has asked for the wisdom of the Perl Monks concerning the following question:
Good afternoon dear Monks,
I'm attempting to search logs using tail -f so if the specific string got into the log file we should print the first 3 occurrences and continue the rest of the script, but it is not working. The strings passed as a commandline argument.
I appreciate the your valuable input
use warnings; use strict; my $currentDate = `date +%Y%m%d`; my $logPath = "/dhcp/logs" my $logFile = "{$path}/DHCPD.log.{$currentDate}" my @tail = qx(tail -f -1 $logFile | grep $_); if (@tail) { print @slice = @tail[0 - 2]; last; } else { print "not found"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Watch log for string (tail -f)
by BrowserUk (Patriarch) on Oct 11, 2012 at 20:19 UTC | |
by hmb104 (Sexton) on Oct 11, 2012 at 20:25 UTC | |
by BrowserUk (Patriarch) on Oct 11, 2012 at 20:45 UTC | |
by bimleshsharma (Beadle) on Oct 12, 2012 at 07:39 UTC | |
by Skootaman (Novice) on Sep 30, 2013 at 11:44 UTC | |
Re: Watch log for string (tail -f)
by roboticus (Chancellor) on Oct 11, 2012 at 20:25 UTC | |
Re: Watch log for string (tail -f)
by brap (Pilgrim) on Oct 11, 2012 at 20:24 UTC | |
Re: Watch log for string (tail -f)
by live4tech (Sexton) on Oct 12, 2012 at 11:01 UTC | |
by hmb104 (Sexton) on Oct 12, 2012 at 15:24 UTC | |
by live4tech (Sexton) on Oct 14, 2012 at 04:41 UTC |
Back to
Seekers of Perl Wisdom