Is it possible to record all the output of a Mathematica
script to a file? I am looking for the Mathematica
equivalent of fortran ./a.out > out.dat
which record all the output string to the file out.dat
.
Using OpenWrite[]
and WriteString[]
can record only the part I can specify but not the error messages which also can appear during execution. For example consider the script test.m
Print@"Start";
x=1/0;
Print@x;
Quit[];
If you run math -script test.m
it will produce a message about encountering 1/0 apart from the string "Start" and "ComplexInfinity" due to the Print
. I want to record all these messages in a file. Is it possible?
Clarification
When you run a script in terminal it produces different messages, both user defined (with Print
) or machine generated (like error messages). In a note book they are automatically recorded. But when running the script in background in a remote machine, it is not possible to keep track of all the messages. So I am looking for a way to record them in a file so that I can get an idea of the progress at any instance by looking at that file.