That was a typo and I have fxed it. I'm still not getting any idea abou7t how to do this, and how to break out the tail -f?
This is what I got so far:
#!/NMS/perl/ACTIVE/bin/perl -w use warnings; use strict; #variables my $currentDate = `date +%Y%m%d`; my $logPath = "/logs"; my $logFile = "$logPath/log.$currentDate"; my $ipaddress = $ARGV[0]; my @tail = `tail -f $logFile | grep $ipaddress`; #print "Log file: $logFile\n"; #print "IP address: $ipaddress\n"; # script begins if (@tail) { my @lines = $tail[0 - 2]; print @lines; exit(0); } else { print "not found"; exit(1); }
In reply to Re^2: Watch log for string (tail -f)
by hmb104
in thread Watch log for string (tail -f)
by hmb104
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |