Command line Mathematica on Mac OS X

February 27th, 2010 | Categories: Mac OS X, mathematica | Tags:

On a Linux machine with a normal install of Mathematica you can usually get access to a command line version of Mathematica by typing

math

at the command line.  Command line Mathematica is useful for situations where you want to do batch processing, perhaps as part of a Condor pool or something, but I’ll not write about that until another time.

On a Mac, however, a standard install of Mathematica doesn’t give you a math command so you have to create it yourself.  Add the following line to your system’s /etc/bashrc file.

alias math="/Applications/Mathematica.app/Contents/MacOS/MathKernel"

Now, when you type math at the command prompt it will behave just like a Linux system which is sometimes useful.

  1. Szabolcs
    February 27th, 2010 at 16:47
    Reply | Quote | #1

    That’s unusual. Even the Windows version includes math.exe, which runs in command line mode, in addition to MathKernel.exe, which draws its own terminal window.

  2. GG
    February 28th, 2010 at 01:00
    Reply | Quote | #2

    Why on earth, in the year 2010, should anyone want to use a command line version of any program?

    PS:
    I’m 43 and ages ago I was using command line progs…

  3. February 28th, 2010 at 10:08
    Reply | Quote | #3

    Hi GG

    I use command line programs all the time for system administration and so on. Simply put – they can be significantly faster than GUI alternatives when you know what you are doing. I’m not particularly hardcore about this though – I use GUIs when it makes more sense to.

    As for command line Mathematica – the reason I am interested in it is because I am collaborating on a research project that is in need of some batch processing via Condor and using command line mathematica is the easiest (only?) way to do this. Maybe I’ll blog about the details sometime.

    Cheers,
    Mike

  4. March 4th, 2010 at 21:16
    Reply | Quote | #4

    For Maple it’s
    /Library/Frameworks/Maple.framework/Versions/Current/bin/maple

  5. November 24th, 2010 at 22:17
    Reply | Quote | #5

    @GG, another reason might be if you’re using Mathematica remotely. That’s why I came across this post: I want to run a simulation on a powerful Mac workstation over ssh, but I couldn’t figure out how to run Mathematica from the commandline. Thanks, Mike!