Re: bsdgrep does not work with tail -f | grep combination

2010-08-18 Thread poyopoyo
Hi Gabor and others,

As Gabor committed r211364, bsdgrep now works nicely with tail -f.

http://svn.freebsd.org/changeset/base/211364

Thank you very much.

-- 
kuro
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: bsdgrep does not work with tail -f | grep combination

2010-08-18 Thread Gabor Kovesdan

 Em 2010.08.18. 7:42, poyop...@puripuri.plala.or.jp escreveu:

Hi Gabor and others,

As Gabor committed r211364, bsdgrep now works nicely with tail -f.

http://svn.freebsd.org/changeset/base/211364

Thank you very much.
Acknowledgements also go to you and other users. Without quality 
feedback I may not have found myself all reported bugs.


Gabor

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: bsdgrep does not work with tail -f | grep combination

2010-08-04 Thread jhell

On 08/03/2010 14:21, Gabor Kovesdan wrote:

Em 2010.08.03. 19:25, poyop...@puripuri.plala.or.jp escreveu:

Hi,

It seems bsdgrep does not work when piped from tail -f.
I'm running r210728.

term0$ jot 10 /tmp/1
term0$ tail -f /tmp/1 | grep 0
[no output]

otherterm$ jot 10 /tmp/1
[no output to term0]

=

with GNU grep:

term0$ tail -f /tmp/1 | gnugrep 0
10
otherterm$ jot 10 /tmp/1
[on term0]
10
10

I've checked on 8.0 and GNU grep doesn't output anything either for me.
If you use tail -f, you will enter more lines and end it with EOF, won't
you? And then BSD grep will process the input and print out matches. I
don't think it's bad behaviour in itself but if you can explain why you
think it's bad I'm willing to change it.



This is a common functionality gnu-grep. tail -f never exits and grep 
keeps grepping until it gets a EOF which is never hit unless you ^C.


A good example for such a use is monitoring a all.log log while looking 
for non-exact situations. something like


% tail -f all.log |egrep -v (sendmail|sm-mta|cron)

which would remove all lines that contain sendmail sm-mta  cron from 
the output and continue to read output from tail -f until it is ^C.


You can turn on your all.log through /etc/syslog.conf after creating the 
mode 600 file under /var/log for toying with.


There is quite a few other cases but I don't think I need to mention 
them. I rely on this for continuous firewall log trolling.


No offense but If the functionality exists in gnu-grep then the same 
functionality needs to exist in bsd-grep, ``period''. At least for the 
mean-time.



Regards,

--

 jhell,v

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: bsdgrep does not work with tail -f | grep combination

2010-08-04 Thread Alexandre Sunny Kovalenko
On Tue, 2010-08-03 at 20:21 +0200, Gabor Kovesdan wrote:
 Em 2010.08.03. 19:25, poyop...@puripuri.plala.or.jp escreveu:
  Hi,
 
  It seems bsdgrep does not work when piped from tail -f.
  I'm running r210728.
 
  term0$ jot 10  /tmp/1
  term0$ tail -f /tmp/1 | grep 0
  [no output]
 
  otherterm$ jot 10  /tmp/1
  [no output to term0]
 
  =
 
  with GNU grep:
 
  term0$ tail -f /tmp/1 | gnugrep 0
  10
  otherterm$ jot 10  /tmp/1
  [on term0]
  10
  10
 
 I've checked on 8.0 and GNU grep doesn't output anything either for me. 
 If you use tail -f, you will enter more lines and end it with EOF, won't 
 you? And then BSD grep will process the input and print out matches. I 
 don't think it's bad behaviour in itself but if you can explain why you 
 think it's bad I'm willing to change it.
 
I am not sure it is specific to the GNU grep -- below is the example
from AIX 5.3:

su...@irptdev_1tail -f engine.log | grep Hello
Aug  4 10:41:39 irptdev_1 local3:debug sunny: Hello Wed Aug 4 10:41:39
EDT 2010 
Aug  4 10:41:46 irptdev_1 local3:debug sunny: Hello Wed Aug 4 10:41:46
EDT 2010 
Aug  4 10:41:57 irptdev_1 local3:debug sunny: Hello Wed Aug 4 10:41:57
EDT 2010 

I am doing 

su...@irptdev_1logger -p local3.debug Hello `date`
su...@irptdev_1logger -p local3.debug Hello `date`
su...@irptdev_1logger -p local3.debug Hello `date`

from different terminal window.

HTH,
-- 
Alexandre Kovalenko (Олександр Коваленко)



--
Ovi Mail: Making email access easy
http://mail.ovi.com

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: bsdgrep does not work with tail -f | grep combination

2010-08-04 Thread Lars Engels
On Wed, Aug 04, 2010 at 10:51:08AM -0400, Alexandre Sunny Kovalenko wrote:
 On Tue, 2010-08-03 at 20:21 +0200, Gabor Kovesdan wrote:
  Em 2010.08.03. 19:25, poyop...@puripuri.plala.or.jp escreveu:
   Hi,
  
   It seems bsdgrep does not work when piped from tail -f.
   I'm running r210728.
  
   term0$ jot 10  /tmp/1
   term0$ tail -f /tmp/1 | grep 0
   [no output]
  
   otherterm$ jot 10  /tmp/1
   [no output to term0]
  
   =
  
   with GNU grep:
  
   term0$ tail -f /tmp/1 | gnugrep 0
   10
   otherterm$ jot 10  /tmp/1
   [on term0]
   10
   10
  
  I've checked on 8.0 and GNU grep doesn't output anything either for me. 
  If you use tail -f, you will enter more lines and end it with EOF, won't 
  you? And then BSD grep will process the input and print out matches. I 
  don't think it's bad behaviour in itself but if you can explain why you 
  think it's bad I'm willing to change it.
  
 I am not sure it is specific to the GNU grep -- below is the example
 from AIX 5.3:

[...]

Same on Solaris, so this is not a GNU feature.


pgpGldYyM2bSl.pgp
Description: PGP signature


Re: bsdgrep does not work with tail -f | grep combination

2010-08-04 Thread freebsd-lists-erik
On Wed, Aug 04, 2010 at 06:28:10PM +0200, Lars Engels wrote:
 On Wed, Aug 04, 2010 at 10:51:08AM -0400, Alexandre Sunny Kovalenko wrote:
  On Tue, 2010-08-03 at 20:21 +0200, Gabor Kovesdan wrote:
   Em 2010.08.03. 19:25, poyop...@puripuri.plala.or.jp escreveu:
Hi,
   
It seems bsdgrep does not work when piped from tail -f.
I'm running r210728.
   
term0$ jot 10  /tmp/1
term0$ tail -f /tmp/1 | grep 0
[no output]
   
otherterm$ jot 10  /tmp/1
[no output to term0]
   
=
   
with GNU grep:
   
term0$ tail -f /tmp/1 | gnugrep 0
10
otherterm$ jot 10  /tmp/1
[on term0]
10
10
   
   I've checked on 8.0 and GNU grep doesn't output anything either for me. 
   If you use tail -f, you will enter more lines and end it with EOF, won't 
   you? And then BSD grep will process the input and print out matches. I 
   don't think it's bad behaviour in itself but if you can explain why you 
   think it's bad I'm willing to change it.
   
  I am not sure it is specific to the GNU grep -- below is the example
  from AIX 5.3:
 
 [...]
 
 Same on Solaris, so this is not a GNU feature.

Why is bsdgrep reading the whole file before processing, anyway?  It
seems like line-by-line processing would be the way to go.

Erik
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: bsdgrep does not work with tail -f | grep combination

2010-08-04 Thread Alexey Shuvaev
On Wed, Aug 04, 2010 at 06:28:10PM +0200, Lars Engels wrote:
 On Wed, Aug 04, 2010 at 10:51:08AM -0400, Alexandre Sunny Kovalenko wrote:
  On Tue, 2010-08-03 at 20:21 +0200, Gabor Kovesdan wrote:
   Em 2010.08.03. 19:25, poyop...@puripuri.plala.or.jp escreveu:
Hi,
   
It seems bsdgrep does not work when piped from tail -f.
I'm running r210728.
   
term0$ jot 10  /tmp/1
term0$ tail -f /tmp/1 | grep 0
[no output]
   
otherterm$ jot 10  /tmp/1
[no output to term0]
   
=
   
with GNU grep:
   
term0$ tail -f /tmp/1 | gnugrep 0
10
otherterm$ jot 10  /tmp/1
[on term0]
10
10
   
   I've checked on 8.0 and GNU grep doesn't output anything either for me. 
   If you use tail -f, you will enter more lines and end it with EOF, won't 
   you? And then BSD grep will process the input and print out matches. I 
   don't think it's bad behaviour in itself but if you can explain why you 
   think it's bad I'm willing to change it.
   
  I am not sure it is specific to the GNU grep -- below is the example
  from AIX 5.3:
 
 [...]
 
 Same on Solaris, so this is not a GNU feature.

Just to clarify things, bsdgrep of course works with tail -f,
the data just sits in its buffer:

~ jot 10  test
~ tail -f test | grep 0

[on another terminal]

~ jot 10  test

[nothing happens on original terminal]

~ jot 4000  test

[on the original terminal]

10
10
10
20
30
40
50
60
70
80
90
100
101
102
103
[snip]
3950
3960
3970
3980
3990
4000

Alexey.
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: bsdgrep does not work with tail -f | grep combination

2010-08-04 Thread pluknet
On 4 August 2010 20:28, Lars Engels lars.eng...@0x20.net wrote:
 On Wed, Aug 04, 2010 at 10:51:08AM -0400, Alexandre Sunny Kovalenko wrote:
 On Tue, 2010-08-03 at 20:21 +0200, Gabor Kovesdan wrote:
  Em 2010.08.03. 19:25, poyop...@puripuri.plala.or.jp escreveu:
   Hi,
  
   It seems bsdgrep does not work when piped from tail -f.
   I'm running r210728.
  
   term0$ jot 10  /tmp/1
   term0$ tail -f /tmp/1 | grep 0
   [no output]
  
   otherterm$ jot 10  /tmp/1
   [no output to term0]
  
   =
  
   with GNU grep:
  
   term0$ tail -f /tmp/1 | gnugrep 0
   10
   otherterm$ jot 10  /tmp/1
   [on term0]
   10
   10
  
  I've checked on 8.0 and GNU grep doesn't output anything either for me.
  If you use tail -f, you will enter more lines and end it with EOF, won't
  you? And then BSD grep will process the input and print out matches. I
  don't think it's bad behaviour in itself but if you can explain why you
  think it's bad I'm willing to change it.
 
 I am not sure it is specific to the GNU grep -- below is the example
 from AIX 5.3:

 [...]

 Same on Solaris, so this is not a GNU feature.


By the way, egrep from 4.4BSD-Alpha used read(2) with 8k blocks.
I justed checked, it works with tail -f.

-- 
wbr,
pluknet
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: bsdgrep does not work with tail -f | grep combination

2010-08-04 Thread Sean C. Farley

On Tue, 3 Aug 2010, Gabor Kovesdan wrote:


Em 2010.08.03. 19:25, poyop...@puripuri.plala.or.jp escreveu:

Hi,

It seems bsdgrep does not work when piped from tail -f.
I'm running r210728.

term0$ jot 10  /tmp/1
term0$ tail -f /tmp/1 | grep 0
[no output]

otherterm$ jot 10  /tmp/1
[no output to term0]

=

with GNU grep:

term0$ tail -f /tmp/1 | gnugrep 0
10
otherterm$ jot 10  /tmp/1
[on term0]
10
10

I've checked on 8.0 and GNU grep doesn't output anything either for me. If 
you use tail -f, you will enter more lines and end it with EOF, won't you? 
And then BSD grep will process the input and print out matches. I don't think 
it's bad behaviour in itself but if you can explain why you think it's bad 
I'm willing to change it.


On 8.1, GNU grep (from system) and FreeGrep (personal repo with my 
fastcomp changes) both output the '10' from this test.  Are you sure you 
ran GNU grep on that system and did not accidentally run a copy of BSD 
grep?


With bsdgrep in HEAD, I think it is not processing the input until 
stdio's buffer is flushed at the 8KB mark.  I barely looked at the code, 
so I am merely surmising.


Sean
--
s...@freebsd.org
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: bsdgrep does not work with tail -f | grep combination

2010-08-04 Thread Xin LI
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 2010/08/03 11:21, Gabor Kovesdan wrote:
 I've checked on 8.0 and GNU grep doesn't output anything either for me.
 If you use tail -f, you will enter more lines and end it with EOF, won't
 you? And then BSD grep will process the input and print out matches. I
 don't think it's bad behaviour in itself but if you can explain why you
 think it's bad I'm willing to change it.

I'm able to reproduce the GNU behavior on 9.0-CURRENT which is IMO right.

I think we need to break at the line end to provide better interactivity
(the current code seems to do it (buffer is not full  !eof), while
what we wanted is (buffer is not full  !eof  !eol).

The attached patch should fix this but I have not yet thoroughly tested
it due to job work.

Cheers,
- -- 
Xin LI delp...@delphij.nethttp://www.delphij.net/
FreeBSD - The Power to Serve!  Live free or die
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.16 (FreeBSD)

iQEcBAEBCAAGBQJMWawXAAoJEATO+BI/yjfBigMIAM2PHLXm2Qz4Kzhd8y+NYc2S
VKJVzNv6DAVMyqCXbezp6d+Qt4sls31uvFhizS9e6HZdUolqV4/m5AiM9UcF2wK4
i49PoQPSBs3Gpp0fuM4kxlZCp843ABkZfeYr2oFZluEA144jlA2bwrX598hmo2Ge
ikpljC/4R8e6TOdTNobcV4jTeHCcGYZv5nmCmODY4DZoGkFjXNQJL/zpHLYgaNyn
0j9TZ1okhaG/jLATlc+UhtyetB/wkN8VGNDyxQNg4a7iMw0xkqjoxMVpsoF4uoXS
YOcSEOXuvwHxs6jlkH7z0u06bmqqdv7Okw4OSANvGN35AuB7OQDrJWHdPBS9DZA=
=pZe0
-END PGP SIGNATURE-
Index: file.c
===
--- file.c  (revision 210851)
+++ file.c  (working copy)
@@ -139,7 +139,7 @@
 
while (i  bufsiz) {
ch = grep_fgetc(f);
-   if (ch == EOF)
+   if (ch == EOF || ch == '\n')
break;
binbuf[i++] = ch;
}
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org

Re: bsdgrep does not work with tail -f | grep combination

2010-08-04 Thread Bakul Shah
On Tue, 03 Aug 2010 20:21:56 +0200 Gabor Kovesdan ga...@freebsd.org  wrote:
 Em 2010.08.03. 19:25, poyop...@puripuri.plala.or.jp escreveu:
  Hi,
 
  It seems bsdgrep does not work when piped from tail -f.
  I'm running r210728.
 
  term0$ jot 10  /tmp/1
  term0$ tail -f /tmp/1 | grep 0
  [no output]
 
  otherterm$ jot 10  /tmp/1
  [no output to term0]
 
  =
 
  with GNU grep:
 
  term0$ tail -f /tmp/1 | gnugrep 0
  10
  otherterm$ jot 10  /tmp/1
  [on term0]
  10
  10
 
 I've checked on 8.0 and GNU grep doesn't output anything either for me. 
 If you use tail -f, you will enter more lines and end it with EOF, won't 
 you? And then BSD grep will process the input and print out matches. I 
 don't think it's bad behaviour in itself but if you can explain why you 
 think it's bad I'm willing to change it.

This is more fundamental, not just limited to grep.  tail -f
never closes its stdout channel so the next process in the
pipeline will never seen an EOF on its stdin and must
continue processing its input. Try this:

rm -f /tmp/1; touch /tmp/1
tail -f /tmp/1 | cat 
while sleep 1; do date  /tmp/1; done

Notice how cat doesn't quit. In fact

tail -f /tmp/1 | bsdgrep ''

must behave exactly the same as 

tail -f /tmp/1 | cat

and so must this:

tail -f /tmp/1 | cat | bsdgrep ''

bsdgrep when used this way doesn't quit but doesn't do
anything either (including printing what tail -f spits out
from existing file data). This is just a bug.
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: bsdgrep does not work with tail -f | grep combination

2010-08-04 Thread Gabor Kovesdan

Em 2010.08.04. 20:06, Xin LI escreveu:

I'm able to reproduce the GNU behavior on 9.0-CURRENT which is IMO right.

I think we need to break at the line end to provide better interactivity
(the current code seems to do it (buffer is not full  !eof), while
what we wanted is (buffer is not full  !eof  !eol).

The attached patch should fix this but I have not yet thoroughly tested
it due to job work.

   
I think the patch may break binary detection. That buffer is not a 
general buffer but filled in only once with the first n bytes of the 
file to check if the file is binary. If you stop after the first line, 
only the first line will be used for binary checking. I'll look at this 
problem soon.


Gabor
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: bsdgrep does not work with tail -f | grep combination

2010-08-04 Thread Doug Barton

On 08/04/10 11:18, Bakul Shah wrote:

bsdgrep when used this way doesn't quit but doesn't do
anything either (including printing what tail -f spits out
from existing file data).


Does adding --line-buffered to the grep command line change the behavior 
at all?


--

Improve the effectiveness of your Internet presence with
a domain name makeover!http://SupersetSolutions.com/

Computers are useless. They can only give you answers.
-- Pablo Picasso

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: bsdgrep does not work with tail -f | grep combination

2010-08-03 Thread Gabor Kovesdan

Em 2010.08.03. 19:25, poyop...@puripuri.plala.or.jp escreveu:

Hi,

It seems bsdgrep does not work when piped from tail -f.
I'm running r210728.

term0$ jot 10  /tmp/1
term0$ tail -f /tmp/1 | grep 0
[no output]

otherterm$ jot 10  /tmp/1
[no output to term0]

=

with GNU grep:

term0$ tail -f /tmp/1 | gnugrep 0
10
otherterm$ jot 10  /tmp/1
[on term0]
10
10
   
I've checked on 8.0 and GNU grep doesn't output anything either for me. 
If you use tail -f, you will enter more lines and end it with EOF, won't 
you? And then BSD grep will process the input and print out matches. I 
don't think it's bad behaviour in itself but if you can explain why you 
think it's bad I'm willing to change it.


Thanks for your comment,

Gabor

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org