logging session automatically



Pol,

> I would like to log sessions automatically, saving to a file created
> at the start, then closing before exiting maxima. (both on linux and on
> mswindows)

I think writefile & closefile should do the job. However the
underlying Lisp stuff (DRIBBLE + i/o streams) is not implemented
the same by all Lisps. In particular writefile + GCL + Windows
doesn't work correctly. (I tried it the other day and found that end
of line characters were not put in the right places; makes the file
more or less unreadable.)
Also writefile + SBCL + Linux seems to not capture input (only output).
Since DRIBBLE + SBCL works OK, I'm guessing this has to do with
which streams are pointing where ...

A console log seems to be a fairly common request; we (Maxima)
might want to get writefile to work the same for all Lisp varieties.

> I have tried using 'writefile', but i wasn't able to execute
> maxima batch commands without exiting in the end.

I'm sorry, I don't understand what you mean by this.
Can you be more specific?

> Moreover, i wasn't able to create the file exploiting system utilities
> to include date in the filename.

Hmm. Maybe this is helpful:

; put this in a file and load it
(defun $timestamp () (multiple-value-bind (second minute hour date
month year day-of-week dst-p tz) (get-decoded-time) (format nil
"~d-~2,'0d-~2,'0d-~2,'0d-~2,'0d-~2,'0d" year month date hour minute
second)))

/* now in your Maxima session ... */
timestamp();
  => 2007-01-15-08-15-02
filename: concat ("/tmp/maxima-log-", timestamp());
  => /tmp/maxima-log-2007-01-15-08-16-08
writefile (filename);
<stuff goes here>
closefile ();

Hope this helps
Robert Dodier