Capturing process output (STDOUT, STDERR) via input, output redirection

Last edited on


To capture all output of a process/program (for example squishserver and squishrunner) the I/O redirection functionality commonly found in “shell” programs (bash and others on Unix systems, cmd.exe on Windows) can be used.

For example:

myprogram >stdout.txt 2>stderr.txt
Execute this in a shell/cmd.exe

Merging STDOUT and STDERR into a single file

To merge the STDOUT and STDERR channels and redirect them into a single file:

myprogram >stdout.txt 2>&1

In this, the order is often relevant, so the “2>&1” part should appear at the end.

Executing commands in/with a new console window (Windows)

To start a process in a new, separate console window - and still capture its output - cmd.exe must be used together with the “start” (command which is built into cmd.exe):

start cmd.exe /c "squishserver --verbose >squishserver_out.txt 2>&1"

Note that the parameters for the new process (squishserver in the above example) needs to be passed as a single parameter to cmd.exe and be enclosed in double quotes.