How to? tpipe grep stdout?

Mar 19, 2013
4
0
Can tpipe /grep be used to grep the output of a program? My RTFM/experimentation has so far failed...

A program I run from the command line produces very verbose output, most of which I don't care about. What I'd like to do is filter this output to just the stuff I do care about.

E.g. foo.exe | tpipe /grep=3,0,0,1,0,1,1,1,"bar"

Or am I trying to use the wrong hammer?

Thanks!
 
May 20, 2008
12,165
133
Syracuse, NY, USA
Right hammer. And it should work. Are you sure foo.exe outputs lowercase "bar" to stdout? I wouldn't expect it to work if a program didn't write to stdout (for example, if it used WriteConsole()).

Code:
v:\> netstat | tpipe /grep=3,0,0,1,0,1,1,1,"Proto"
  Proto  Local Address          Foreign Address        State
 
Mar 19, 2013
4
0
Ah, tpipe processes the output after the program is finished.

And, given that, I think you are right that the program must use WriteConsole, since I see unfiltered output while the program is running.

So what I need instead I guess is some way of filtering what goes to the console (or what shows up in the scrollback buffer)...
 
May 20, 2008
12,165
133
Syracuse, NY, USA
It's somewhat odd that a console app **not** use stdout. I'd expect such an app to have a write_to_file option. If your app has such an option TPIPE could be used to process the file. If your app isn't writing to stdout, I don't think redirection (>) will help get its output into a file.

Another thought ... is it possible your app is writing to stderr?
 
Mar 19, 2013
4
0
Turns out it is using stdout (and stderr as well).

Interestingly, I typically run the program via a toolbar button - which, when I add the '| tpipe /grep...' to the "command", exhibits the behavior I described above (nothing filtered, everything goes to the scrollback buffer immediately).

If I instead run the program with tpipe from the prompt rather than from a button, tpipe /grep... works as expected (though not as I'd hoped) - stdout is buffered until the program exits and is then grep'd, stderr is displayed immediately.

I'd hoped to be able to filter in "realtime". But supressing/filtering stdout until exit while displaying stderr is close enough.

Thank you!
 

Similar threads