I have a process I need to run within a batch file. This process produces some output. I need to both display this output to the screen and send (pipe) it to another program.
The bash method uses
echo 'ee' | tee /dev/tty | foo
Is there an equivalent for Windows? I am happy to use PowerShell if necessary.
tee ports for Windows, but there does not appear to be an equivalent for
/dev/tty, which complicates matters.
The specific use-case here: I have a program (launch4j) that I need to run, displaying output to the user. At the same time, I need to be able to detect success or failure in the script. Unfortunately, this program does not set an exit code, and I cannot force it to do so. My current workaround involves piping to
find, to search the output (
launch4j config.xml | find "Successfully created") - however, that swallows the output I need to display. Therefore, I need some way to both display to the screen and send the ouput to a command - and this command should be able to set
ERRORLEVEL (it cannot run asynchronously). This will be used in a build script, which could be run on many different machines.
For this particular case, something lightweight is required - I cannot install additional frameworks or interpreters (e.g. perl as suggested in this answer). Also, any commercial programs must have a licence that allows redistribution.