Ask Your Question
0

Saving my sage session into a .txt file from Interactive Shell

asked 2015-11-27 15:02:48 -0500

bruno171092 gravatar image

Hello guys, I have the following question:

Lets say i run a sage session and at the end i got this written in my Interactive Shell after the session

sage: Zmod(7)
Ring of integers modulo 7
sage: R.<x> = Zmod(7)[]
sage: R
Univariate Polynomial Ring in x over Ring of integers modulo 7
sage: RR = R.quotient(x^7 - 1)
sage: RR
Univariate Quotient Polynomial Ring in xbar over Ring of integers modulo 7 with modulus x^7 + 6
sage: f = RR(x^6-x^4+x^3+x^2-1)
sage: f
xbar^6 + 6*xbar^4 + xbar^3 + xbar^2 + 6

And now i want to save all of the above into a txt-file. Is that possible and when yes how?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-11-27 18:22:11 -0500

nbruin gravatar image

IPython's %history magic command is probably what you're looking for. It has a -f option to redirect to a file. See %history? for the relevant documentation. It may not be formatted exactly how you want, but it should get you pretty close.

An alternative is to run inside an emacs buffer or "screen" and use its save functions.

edit flag offensive delete link more

Comments

Hmm i used the history command.... but now i dont find the file -_- I even searched for it with the windows-function... but nothign is found... God... that Virtual Machine for Windows is frustrating... Do you have Linux or Windows yourself?

bruno171092 gravatar imagebruno171092 ( 2015-11-28 04:15:42 -0500 )edit

IPython would have saved it in the working directory of the process. If you do

sage: %history -f hist.txt
sage: ls hist.txt
hist.txt

You can confirm the file exists. To find out what the working directory is:

sage: pwd
u'/home/<something>'

Once you know where the file is, al you need to do is figure out a way of transferring files between your VM and the host OS. I hope that problem is addressed in the VM documentation somewhere.

nbruin gravatar imagenbruin ( 2015-11-28 12:59:16 -0500 )edit

Well thanks a lot... I got out, that the path is

/home/sage

but unfortunately i have no clue how i get there... Sorry buddy, that i am still not able to do it after all your efforts :/

bruno171092 gravatar imagebruno171092 ( 2015-11-28 13:52:52 -0500 )edit

Does the information at http://wiki.sagemath.org/SageApplianc... still apply? As long as you have one place that is accessible from both windows and your VM, you can move the file to that location for transport.

Come to think of it, you could try in the notebook:

sage: cp /home/sage/history.txt .

that should copy the file into the working directory of the active cell, and files dropped there should be hyperlinked. So if you access the notebook from a windows-based browser, you can possibly get at that file that way. Otherwise sftp-ing into the VM might be an option (PuTTY on windows has that capability I believe). This is just basic plumbing that you might want to learn anyway.

nbruin gravatar imagenbruin ( 2015-11-28 14:03:11 -0500 )edit

well the information is right except that my files arent saved there anyway. and your tipp with notebook isnt working either. "cp" is not defined...

I have no clue what sftop-ing is... and I somehow feel like i am a little bit too much of an computer noob to get it right...

bruno171092 gravatar imagebruno171092 ( 2015-11-28 15:06:39 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-11-27 15:02:48 -0500

Seen: 365 times

Last updated: Nov 27 '15