tail / grep

Joseph Key keyj001 at hawaii.rr.com
Fri Nov 17 00:21:02 PST 2000


I tried it with out the grep -f and I still didn't get any output.  Removing
grep made the pipe work correctly.  I wonder if it is grep needs to see the
end of the file before it can process the list.  So the tail -f never gives
an end of file so grep never processes the information.  I also tried using
sed -n /(word to search for)/ p and I still didn't get any output till I
killed the tail command.  What if you instead of running the tail command
with the -f option.  You ran the tail without the -f option using a cron
job.  If that might make you miss something try running the whole file thru
grep saving the file to disk.  Then using diff to catch the differences
between that disk file and the previous saved file.  Outputting the result
to a log/save file or sent to you via mail.  Then all you need to do is run
the script via cron often enough for what you need the info for.

An example of this type of script can be found in
security-script-0.07.tar.gz.  I found the file on Freshmeat.  It is a port
of a security script use by one of the BSD distros.  I run it on my system
and it mails me about changes to various parts of my system.

Joseph Key

----- Original Message -----
From: "Mike Ballon" <calzonie at hawaii.rr.com>
To: "Linux Users Anonymous" <luau at luau.hi.net>
Sent: Thursday, November 16, 2000 9:13 PM
Subject: [luau] Re: tail / grep


> I think the grep -f is putting it in a loop from what I can tell, so
> basically the next command ">" is never getting run.  It works great if
you
> just use |grep word with the tail, the grep -f is what's throwing things
off
> for sure.
>
> This was actually just something I was playing with and now it's got my
> stumped.
>
> ----- Original Message -----
> From: "Joseph Key" <keyj001 at hawaii.rr.com>
> To: "Linux Users Anonymous" <luau at luau.hi.net>
> Sent: Thursday, November 16, 2000 6:34 PM
> Subject: [luau] Re: tail / grep
>
>
> > I did some more testing and found.  If you remove the grep the command
> works
> > like it should.  I put tee instead of redirecting and found that it
works
> > without the grep but as soon as you try and grep the output of the tail
> all
> > output stops till the tail command is killed (if you control-c the whole
> > command the command line and output file are empty).  I tried putting
what
> > is to be grepped on the command line and still no output.
> >
> > Joseph Key
> >
> > ----- Original Message -----
> > From: "Mike Ballon" <calzonie at hawaii.rr.com>
> > To: "Linux Users Anonymous" <luau at luau.hi.net>
> > Sent: Thursday, November 16, 2000 6:10 PM
> > Subject: [luau] Re: tail / grep
> >
> >
> > > I'll have to wait until tomorrow to try this, thanks.
> > >
> > > ----- Original Message -----
> > > From: "Joseph Key" <keyj001 at hawaii.rr.com>
> > > To: "Linux Users Anonymous" <luau at luau.hi.net>
> > > Sent: Thursday, November 16, 2000 5:15 PM
> > > Subject: [luau] Re: tail / grep
> > >
> > >
> > > > I did some testing of a tail followed by a grep redirected to a
file.
> I
> > > > found that when the command is run without the -f in the tail it
works
> > > fine.
> > > > Why are you using -f in tail?  I think the problem is to get a
useful
> > > output
> > > > you need to end with a control-c this kills the tail and grep before
> > they
> > > > can redirect.  The file is open but doesn't get anything till the
> > command
> > > > ends.  I found that if you ps ax and just kill the tail command the
> > > redirect
> > > > works like it should.  Hope this helps.
> > > >
> > > > Joseph Key
> > > >
> > > > ----- Original Message -----
> > > > From: "Mike Ballon" <calzonie at hawaii.rr.com>
> > > > To: "Linux Users Anonymous" <luau at luau.hi.net>
> > > > Sent: Thursday, November 16, 2000 9:48 AM
> > > > Subject: [luau] tail / grep
> > > >
> >
> > > >
> > > > > Here's a good one:
> > > > >
> > > > > tail -f /var/log/squid/access.log | grep -f /etc/Sex.txt >
> > > /tmp/busted.txt
> > > > >
> > > > > The tail part of the command runs, the grep runs (-f read from
file)
> > but
> > > I
> > > > can
> > > > > not get it to output to the /tmp/bustex.txt file to save my life
and
> I
> > > > can't
> > > > > figure out why.  Without using the redirection at the end the
> results
> > of
> > > > the
> > > > > grep are displayed on the crt no problem.
> > > > >
> >
> > > > > What I'm thinking is that the grep -f puts the command in a loop
and
> > it
> > > > never
> > > > > gets to the > redirect portion, you think?
> > > > >
> > > > >
> > > > > ---
> > > > > You are currently subscribed to luau as: keyj001 at hawaii.rr.com
> > > > > To unsubscribe send a blank email to $subst('Email.Unsub')
> > > > >
> > > >
> > > >
> > > > ---
> > > > You are currently subscribed to luau as: calzonie at hawaii.rr.com
> > > > To unsubscribe send a blank email to $subst('Email.Unsub')
> > >
> > >
> > > ---
> > > You are currently subscribed to luau as: keyj001 at hawaii.rr.com
> > > To unsubscribe send a blank email to $subst('Email.Unsub')
> > >
> >
> >
> > ---
> > You are currently subscribed to luau as: calzonie at hawaii.rr.com
> > To unsubscribe send a blank email to $subst('Email.Unsub')
>
>
> ---
> You are currently subscribed to luau as: keyj001 at hawaii.rr.com
> To unsubscribe send a blank email to $subst('Email.Unsub')
>



More information about the LUAU mailing list