How to pass text output from a filter to a command?

  • MJP

    MJP - 2013-02-02

    I'm trying to pass a line of text from sfk filter to a command, like this

    sfk filter ..\logs\app.log -+"server proxy set:" +if "rc=1" run -yes "nircmd trayballoon \"\" \"Registered with [reference to filtered line from the logfile here]\" "

    This works except I failed to find a method to get log search result into the argument of my command line.

    More generally: how do i run phased text processing, like: run filter1, pass output to text processor. print the result ? I don't want to use intermediate files created by +tee -toterm - need a clean pipe.

    I would appreciate an example.

  • stahlworks

    stahlworks - 2013-02-05

    right now "+if" does not pass through any data. in your case, it may also not make sense to pass through the filtered lines as is. if the same "server proxy set" lines appears multiple times, it would case "run" being executed multiple times.

    so avoid using "if", and try the following instead:

    sfk -noerror filter ..\logs\app.log "-+server proxy set:" -replace "_*proxy set:__" +filter -unique +run -spat -yes "nircmd trayballoon \q\q \qRegistered with $text\q"

    - you probably don't want the full "server proxy" line text in the nircmd call, but only the right side of line, therefore the replace.
    - filter -unique makes sure that the same "server proxy" line appearing multiple times leads only to one nircmd call. for technical reasons, right now this requires a separate "+filter" statement.
    - if no "server proxy" lines at all are found, -noerror keeps "run" from printing an error.


Log in to post a comment.