0

I am running ngrep on machine to listen to request and response. How can I redirect its output to a file?

I am doing something like this:-

sudo ngrep -q -t "/dummy/v1/xyz" -W byline -d any port 1231  > ngrep_output.txt

But when I am doing tail -f ngrep_output.txt on other screen, I can't see anything.

Once I kill the above process then only I could see the contents in file.

So, it looks like it keeps the result in buffer somewhere? Is there a way I could redirect my output in realtime to the file?

hatellla
  • 4,796
  • 8
  • 49
  • 101
  • I haven't tried this, but looking at the source, you could try either to [not specify `-q`](https://github.com/jpr5/ngrep/blob/master/ngrep.c#L800) or specify [`-l`](https://github.com/jpr5/ngrep/blob/master/ngrep.c#L311). – Kenney Oct 26 '17 at 20:16
  • yes -l worked. Thanks. You can put this in the answer if you want. I can accept it. – hatellla Oct 26 '17 at 20:22

1 Answers1

1

There doesn't seem to be any document describing the commandline arguments to ngrep, but the source code indicates that the -l option turns off output buffering.

Kenney
  • 9,003
  • 15
  • 21