I have an executable, say, process.exe, that reads from stdin and outputs a processed version of it to stdout. What I would like to create is a batch file wrapper that I can call in its place so that only part of the stdin gets processed. Specifically, the part after a certain keyword is detected.
For example, let's say process.exe works by outputting the same lines that are given to it, just with a star added to the end. (It is of course much much complicated, but just as an example.) So if I run it with the following input:
apple
banana
cantaloupe
date
I get
apple*
banana*
cantaloupe*
date*
What I want to do is create a batch file so that only the lines occurring after a line containing my special keyword are processed. So, if the keyword is "keyword" and my input is:
apple
banana
keyword
cantaloupe
date
I want
apple
banana
keyword
cantaloupe*
date*
Note that lines before the keyword are still output to stdout, they are just not passed to process.exe. How can I accomplish this? Ideally, I would like to avoid writing to disk, since the input I will be supplying could be very large. Now, I found out I can use for /F "tokens=*" %%a in ('findstr /n $') do (
in order to loop through stdin line by line, but it seems findstr consumes the entire input, so I can't pass any of it to process.exe...
If such a thing is impossible with Windows Batch Files, how about Powershell?