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.
This redirects the “STDOUT” channel of the “myprogram” application into the file “stdout.txt” in the current working directory (of the shell program).
This redirects the “STDERR” channel of the “myprogram” application into the file “stderr.txt” in the current working directory (of the shell program).
Merging STDOUT and STDERR into a single file¶
To merge the STDOUT and STDERR channels and redirect them into a single file:
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):
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.
Redirecting all Output of a Command or Batch File¶
For this one can use a little helper batch file: capture_output.bat
Note the second (optional) parameter which specifies the to path, and name of the desired output file. When not specified the output file name will be the “command_to_execute” with “.txt” appended to it.