I am trying to redirect all output from a command line programme to a file. I am using Bash. Some of the output is directed to a the file, but some still appears in the terminal and is not stored to the file.
Similar symptoms are described here:
Redirect all output to file in Bash
However, I have tried the proposed solution (capture standard error) without success:
<command> <arguments> > stdout.txt 2> stderr.txt
The file stderr.txt is created, but it is empty.
A possible clue is that the command-line programme is a client communicating with a server on the same machine. It may be that some of the output is coming from the server.
Is there a way to capture all the output from the terminal, irrespective of its origin?
I've confirmed that the missing output is generated by the server. Running the command in a separate terminal causes some output in both terminals, I can pipe all the output from the command terminal to a file. This raises issues about how to capture the server output, but that's a different question.
/dev/tty, instead of one of the standard output streams, there's no (simple) way to capture that. There's also the possibility that it might be duplicating the stdout/stderr file descriptors to another file descriptor and writing there, which you could capture (e.g.... 3> somefile), but you would have to know what file descriptor is being used...