Output redirection doesn't work for a certain program Output redirection doesn't work for a certain program linux linux

Output redirection doesn't work for a certain program


progname > out.txt 2>&1

Edit: If you actually did this and it was a typo in your question. It might be possible that the application checks if the output is a TTY.

Edit2: Ok, in that case, try script -qc progname > out.txt > 2>&1

In Debian/Ubuntu, script is a part of the bsdutils package which is an Essential package and always installed.


Based on your strace it sounds like the program is testing if stdin and/our stdout is a tty. I've never used it but you could try using empty.sourceforge.net. It's suppose to create a pseudo-tty which should fool your program's check.


Try to redirect a single stream at a time to /dev/null, to see which one it prints on:

progname > /dev/nullprogname 2> /dev/null

Then you'll see which stream you have to capture. For technical reasons some programs print even informational messages on stdout.