1
$\begingroup$

tmp.m file:

tmp = Table[RandomReal[], {3}, {4}]
Export["test.xlsx", tmp]
Quit[]

Then

echo "./math -script tmp.m" | at now

Works fine, but it does not close the kernel. The process will be still running.

BUT if I edit tmp.m to

tmp = Table[RandomReal[], {3}, {4}]
Export["test.PDF", TableForm@tmp]
Export["test.xlsx", tmp]
Quit[]

Then

echo "./math -script tmp.m" | at now

Will not run. It does not even save the xlsx file.

So two questions:

How to export PDF file? How to make Quit[] in a script file?

$\endgroup$
4
  • $\begingroup$ Sorry, but this question is really nothing to do with Mathematica. Rather it is about your working environment, and as such, it's very unlikely that we can answer it without simply guessing. About the current directory, it is /proc/<PID>/cwd; to close them kill -TERM <PID>. You will need to become familiar with how your computer is set up and how to work with it, not only for your own sake but because otherwise you risk annoying the administrators and other users with your failed jobs. $\endgroup$ Commented Jan 31, 2015 at 2:28
  • 3
    $\begingroup$ I'm voting to close this question as off-topic because it is basically not about Mathematica itself, but rather the use of it in some unknown environment. The question is therefore unanswerable in this forum. $\endgroup$ Commented Jan 31, 2015 at 2:47
  • $\begingroup$ @OleksandrR. I know how to kill process in linux and how to check the folder. I want to know how Mathematica works in Linux. I have also rephrased my question, hope it is now more Mathematica focused. $\endgroup$ Commented Jan 31, 2015 at 13:40
  • $\begingroup$ both work just fine for me with v10. (Quit[] is not needed ) running directly (i don't have at ). Its either a version issue or something peculiar about at. $\endgroup$
    – george2079
    Commented Aug 28, 2015 at 16:03

1 Answer 1

1
$\begingroup$

Chen, use the following in the terminal and both codes should work just fine:

math -nohup -run "<<tmp.m" > output

any error messages will be in the file "output". When I run this, I get both the excel sheet and the PDF. Now, if you try to export graphics without a frontend you can sometimes run into trouble, but you'll find any error messages in the file.

Edit: I learned about using Mathematica from the command line by reading Jens Noeckel's page.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.