ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 02 Dec 2013 02:48:41 -0600Running sage on an input file via the command linehttps://ask.sagemath.org/question/10793/running-sage-on-an-input-file-via-the-command-line/I have a file abc.sage that contains the commands plot(x^2).show(). From the command line I run "sage abc.sage". The plot command is executed, the viewer appears, and I get a message that a certain png file is not present where expected. Any solutions?Mon, 02 Dec 2013 02:11:36 -0600https://ask.sagemath.org/question/10793/running-sage-on-an-input-file-via-the-command-line/Answer by tmonteil for <p>I have a file abc.sage that contains the commands plot(x^2).show(). From the command line I run "sage abc.sage". The plot command is executed, the viewer appears, and I get a message that a certain png file is not present where expected. Any solutions?</p>
https://ask.sagemath.org/question/10793/running-sage-on-an-input-file-via-the-command-line/?answer=15749#post-id-15749The reason is that the image is stored in a temporary subdirectory of your `~/.sage/temp` directory, but this temporary directory is removed when the execution of your `abc.sage` script is finished (the name of the directory depends on the process that created it). So when your image viewer is launched, it cannot find it anymore. You can check this by adding the line:
sleep(100)
at the end of your abc.sage script, and your image viewer will have the time to get the image before it disapears.
You can also launch Sage and in the Sage command line, and then type:
sage: %runfile abc.sage
Mon, 02 Dec 2013 02:35:24 -0600https://ask.sagemath.org/question/10793/running-sage-on-an-input-file-via-the-command-line/?answer=15749#post-id-15749Comment by sjr for <p>The reason is that the image is stored in a temporary subdirectory of your <code>~/.sage/temp</code> directory, but this temporary directory is removed when the execution of your <code>abc.sage</code> script is finished (the name of the directory depends on the process that created it). So when your image viewer is launched, it cannot find it anymore. You can check this by adding the line:</p>
<pre><code>sleep(100)
</code></pre>
<p>at the end of your abc.sage script, and your image viewer will have the time to get the image before it disapears.</p>
<p>You can also launch Sage and in the Sage command line, and then type:</p>
<pre><code>sage: %runfile abc.sage
</code></pre>
https://ask.sagemath.org/question/10793/running-sage-on-an-input-file-via-the-command-line/?comment=16589#post-id-16589Thanks! Problem solved.Mon, 02 Dec 2013 02:48:41 -0600https://ask.sagemath.org/question/10793/running-sage-on-an-input-file-via-the-command-line/?comment=16589#post-id-16589