1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to? tpipe grep stdout?

Discussion in 'Support' started by lctrc, May 6, 2013.

  1. lctrc

    Joined:
    Mar 19, 2013
    Messages:
    4
    Likes Received:
    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!
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,071
    Likes Received:
    30
    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
     
  3. lctrc

    Joined:
    Mar 19, 2013
    Messages:
    4
    Likes Received:
    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)...
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,071
    Likes Received:
    30
    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?
     
  5. lctrc

    Joined:
    Mar 19, 2013
    Messages:
    4
    Likes Received:
    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!
     
  6. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,201
    Likes Received:
    11

Share This Page