swipl -s jobshop.chr < CHRInput > output 2>&1
2>&1
means “redirect file descriptor 2 (standard error) to whatever file descriptor 1 (standard output) is connected to”. Note that 2>&1
has to come after the redirection of standard ouptput: 2>&1 >output
would first send fd 2 to whatever fd 1 is connected to at the time (i.e. the terminal) then redirect fd 1 to the terminal.
Note that depending on how the program is written, this might not interleave the output in the same order as if it was running on a terminal. That's because many programs buffer the output on stdout, i.e. they only actually write data out when the buffer is full. But when standard output is connected to a terminal, it is line-buffered, i.e. every line is written out even if the buffer is not full. (Stderr, on the other hand, is not buffered by default.) So if the program writes full lines without taking care of flushing buffers or changning default settings and you expect that they come in order whether they were written to standard error or standard output, redirecting to a file might not work.
On reasonably recent Linux systems, if the redirected output has lines out of order, try
stdbuf -oL -oL swipl -s jobshop.chr <CHRInput >output 2>&1