How to write output to an external text file in addition to the standard output stream, i.e. a notebook for a session with FE and stdout for command-line session?
$\begingroup$
$\endgroup$
I expected this to work but it apparently only writes Print
output:
AppendTo[
$Output,
OpenWrite["out.txt", FormatType -> OutputForm]
]
A workaround using $PrePrint
:
output = OpenWrite["out.txt", FormatType -> OutputForm];
$PrePrint = (Write[output, #]; #) &;
-
$\begingroup$ Is it possible to use
PutAppend[]
and notOpenWrite[]
? $\endgroup$ – qazwsx Jun 20 '12 at 3:12 -
1