¿Cómo redirigir la impresión de Mathematica y la impresión de errores a archivos?

¿Cómo redirigir la impresión de Mathematica y la impresión de errores a archivos?

Sometimes, a Mathematica program

  • 1) usos Print[] to print messages,
  • 2) sometimes, there is side-effect type of printing by some functions without any explicit Print[]
  • 3) and sometimes there is error printing.

How to redirect the above three varieties of printing to (separate) text files, so they can be archived (separately) when the Mathematica kernel is closed?

preguntado el 01 de febrero de 12 a las 14:02

Can you give an example of point 2? I am not aware of this. -

I am probably wrong about that there exist the type 2. In Mathematica 8 there is no longer such printing. In some earlier versions, it did, IIRC. -

Relacionado: pregunta. -

1 Respuestas

Print[] by default outputs to the stream $Output. Messages go to the $Messages stream. You can redefine these two global variables to redirect the output to a file:

stream = OpenWrite["out.txt", FormatType -> OutputForm]
$Output = {stream}

Respondido 01 Feb 12, 22:02

-1 for making me look like an ass. ;-p - Señor mago

@Mr.Wizard You see now why I avoid asking questions (you asked me about it once) :)? I upvoted this one, b.t.w. - Leonid Shifrin

To save a bit of face, I must state that I sí logró test the code I included and it worked correctly for the simple scenario I used. - Szabolcs

@Leonid lol -- honestly I wish you would reconsider; you are well respected and I doubt a foolish question would change that. Furthermore I am sure you could ask some really interesting, insightful questions if you chose. - Señor mago

@Szabolcs what's really annoying is that I did not try to solve the problem on my own first, but thought: "oh, here's a good post for mma.SE!" -- I've started a question in Meta relating to this. - Señor mago

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.