[Whonix-devel] How to create a real copy of file descriptors stdout / stderr?
patrick-mailinglists at whonix.org
Mon Feb 27 01:03:00 CET 2017
my goal is to duplicate, redirect all output (stdout and stderr) of an
application (apt-get) to a file while retaining the usual behavior of
apt-get, stdout and stderr.
How to create a real copy of file descriptor stdout and stderr? I would
like to keep stdout and stderr as "natural" as possible. I.e. if it was
running for example apt-get, I would wish to retain colors and progress
By using `tee`, colors and progress information  are lost. Therefore
I experimented with using `unbuffer`, however I would appreciate if both
`unbuffer` and `tee` would not required. 
The following example is partially functional. (The wrapper does more
stuff, just kept it simple.)
exec 1> >(tee -a "$logfile")
#exec 2> >(tee -a "$logfile")
unbuffer apt-get "$@"
Broken: stderr redirection. Once I enable...
exec 2> >(tee -a "$logfile")
...nothing gets written to stdout anymore. Could you advice please on
how to fix this?
22% [8 Packages 3,449 kB/7,098 kB 49%]
kB/s 4min 57s
 To keep the wrapper simpler and dependent on less external binaries.
Otherwise this could cause conflicts with mandatory access control and
More information about the Whonix-devel