0: #!c:/perl/bin/perl -w
1: # Windows doesn't have it
2: # Tail and grep program
3: #
4: use strict;
5:
6: my $file = $ARGV[0] || printUsage();
7: my $gs = $ARGV[1];
8: my $filesize = 0;
9:
10: open (FH,$file) || die "Unable to open $_: $!";
11:
12: seek (FH,0,2);
13: if (tell(FH) >=1500) {
14: seek(FH,-1500,2);
15: } else {
16: seek(FH,0,0);
17: }
18: while (1) {
19: while (<FH>) {
20: if ($gs) {
21: if ($_ =~ /$gs/o) {
22: print $_;
23: }
24: } else {
25: print $_;
26: }
27: }
28: seek(FH,0,1);
29: sleep (1);
30: }
31:
32: sub printUsage {
33: die "USAGE: ptail.exe <filename> [grep string]";
34: }
35:
36: =head1 NAME
37:
38: ptail.pl - A simple tail and grep program.
39: (I was working on NT at the time and needed this)
40:
41: =head1 SYNOPSIS
42:
43: ptail.pl <filename> [grep string]
44:
45: =head1 DESCRIPTION
46:
47: This is a goofy little tool helpful for tailing (and grepping) logfiles.
48:
49: =head1 AUTHOR
50:
51: bizzach, E<lt>wbs@lookiloo.netE<gt>
52:
53: =head1 SEE ALSO
54:
55: L<perl>.
56:
57: =cut
In reply to tail and grep for Windows by bizzach
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |