[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A question about saving program running output
From: Greg Byrd <email@example.com>
> From: firstname.lastname@example.org
> The question is: Is there some easy way to re-direct the
> program's running output to a file ?
Check out the "dribble" function.
An alternatively is to lambda bind *standard-output* to a different
stream object. Assuming you want to see the output as well as make a
file record of it, the stream would be a broadcast-stream (see
make-broadcast-stream) sending to both the file and the original
The two solutions afford slightly different control, so it depends
what you need. (But dribble is easier to use and therefore the best
choice if the differences don't matter.) Dribble side affects the
stream that is the value of *standard-output* to capture _everything_
that is written to >>or read from<< that stream, from the time the
dribble is started until it is ended. On the other hand, rebinding
*standard-output* is more flexible because you can selectively control
the value of *standard-output* for different parts of your program,
thereby controlling what gets recorded and what doesn't. If you
wanted also to record input, you would bind *standard-input* to an
echo stream that writes to the same file.