From: "ara.t.howard" Date: 2008-09-26T01:15:46+09:00 Subject: Re: How to read a PIPE in unbuffered way? On Sep 24, 2008, at 4:33 PM, Iņaki Baz Castillo wrote: > Hi, I'd like to know the Ruby equivalent to the following Perl code: > > --------------------- > open(PIPE,"ngrep dst port 80 |"); > select(PIPE); $| = 1; # make unbuffered > select(STDOUT); $| = 1; # make unbuffered > > while() > { > chomp($_); > s/ > //ig; > s/ // if(/^ /); > #### process and change the captured data before writting to the > screen #### > } > close(PIPE); > ------------------------- > > "ngrep" itself is a Linux command that captures TCP/UDP data and > prints it to > the screen. In this case I capture traffic with destination port 80. > > I assume I must start with: > > f = IO.popen("ngrep dst port 80") > > but no idea of what to do after that. Any help please? Thanks a lot. > > > > -- > Iņaki Baz Castillo > ammunition require 'io/nonblock' http://codeforpeople.com/lib/ruby/nbfifo/nbfifo-0.0.0/README a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama