I am using Linux, and I would like to be able to programmatically open notebooks in a running Mathematica instance from the command line. Currently, doing something like

/opt/Wolfram/Mathematica/8.0/Executables/Mathematica foo.nb

launches a new kernel/frontend instance. Is it possible to re-use a running frontend for opening notebooks (short of enforcing single-instance behavior, for which I believe there is a command line option)?


You can start Mathematica with :

/opt/Wolfram/Mathematica/8.0/Executables/Mathematica -sl &

and then open your notebook in the same session with :

/opt/Wolfram/Mathematica/8.0/Executables/Mathematica -sl foo.nb

From the man page Mathematica --help :

-sl (--singlelaunch): Open in an existing process, if possible.

  • $\begingroup$ Yes, the -sl flag does the trick. Another instance of Mathematica can still be launched by omitting the flag; opening notebooks afterwards with the -sl flag will still be bringing them up in the first instance $\endgroup$ Oct 27 '12 at 20:19
  • 1
    $\begingroup$ It seems it's very important that the first instance is also started with -sl. $\endgroup$
    – Szabolcs
    Jul 17 '15 at 8:51
  • $\begingroup$ Is there an easy way to change the shortcut so this is the default always $\endgroup$
    – William
    Oct 15 '16 at 20:27
  • 2
    $\begingroup$ Its /usr/local/bin/Mathematica -sl in my version of ubuntu but yes it works. $\endgroup$
    – William
    Oct 15 '16 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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