Saving sage output?

1,058 views
Skip to first unread message

Baruch

unread,
May 27, 2009, 10:01:18 PM5/27/09
to sage-support
Please note that I am a complete noob here. I've tried to find the
answer myself, but don't know quite where to turn.

I wanted to save the output of a brief script. I used the logstart
instruction, 'logstart -o filename'. This seemed to give me what I
wanted - the response to this instruction was:

Activating auto-logging, Current session state plus future input
saved.
Filename : filename
Mode : backup
Output logging : true
Raw input logging : false
Timestamping : false
State : active

Despite this, 'filename' contained only the input, not the output.

Is there some way to save output, for example by printing it to a
file?

Any help would be appreciated. Thanks.

javier

unread,
May 28, 2009, 9:05:25 AM5/28/09
to sage-support

Baruch

unread,
May 29, 2009, 2:30:21 AM5/29/09
to sage-support
Thank you, Javier. I appreciate your help.

On May 28, 8:05 am, javier <vengor...@gmail.com> wrote:
> For saving individual objects:
>
> http://www.sagemath.org/doc/tutorial/interactive_shell.html#saving-an...

Dan Drake

unread,
Jun 1, 2009, 8:03:36 PM6/1/09
to sage-s...@googlegroups.com

If you want to save the output of a script, you can just use shell
redirection:

$ sage foo.sage > output.txt

or, to see the output and also put it in the file,

$ sage foo.sage | tee output.txt

You can also, from within your script, write strings to a file: see
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files.

From an interactive command-line session, see log_text, log_dvi, and
log_html, although I just tested log_text and for some reason it's not
putting the output into the log...log_dvi works, though.

Dan

--
--- Dan Drake <dr...@kaist.edu>
----- KAIST Department of Mathematical Sciences
------- http://mathsci.kaist.ac.kr/~drake

signature.asc
Reply all
Reply to author
Forward
0 new messages