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.