Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some code in a file named Demo-3.m, It can be evaluated in Mathematica 9. The final expression in the file is

Export[NotebookDirectory[] <> "fintempimg.jpg", fintempimg];

How can I execute Demo-3.m in Linux using the command-line? Please give me a solution with an example.

share|improve this question
I think you can use script to do this, like math -script file.m. Here has very useful step by step detail. – xslittlegrass Feb 25 '13 at 2:46
Oh my god!! thanks for @xslittlegrass solution, it can work :) – Darren Lee Feb 25 '13 at 2:54
up vote 8 down vote accepted

As xslittlegrass posted in a comment to the question, the file Demo-3.m can be run on Linux by issuing

math -script Demo-3.m

at the command line.

More information on Mathematica scripting can be found here .

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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