I am running a resource extensive notebook, and so I am trying to break it down into a .m file so that I can run it quicker and without using the mathematica interface. The problem is that my notebook needs another package (installed in the usual ~/.Mathematica/Applications/OtherPackage) and I cannot make it load with inside my .m. The usual notebook normally calls the other package as

<< OtherPackage`

But if I add this to the beginning of the script and run

$ math -script script.m

The output goes bananas.

On the other hand, if I start

$ math

and then run

<< OtherPackage`

It loads correctly, and if later I perform

<< script.m

it behaves normally and runs as expected.

My question, is there a way to make my script run in a single go from the command line without having to go to the Tex-Base interface?

  • $\begingroup$ Greetings! Make the most of Mma.SE and take the tour now. Help us to help you, write an excellent question. Edit if improvable, show due diligence, give brief context, include minimum working examples of code and data in formatted form. As you receive give back, vote and answer questions, keep the site useful, be kind, correct mistakes and share what you have learned. $\endgroup$ – rhermans Sep 28 '15 at 14:30
  • $\begingroup$ Can you be more specific than "goes bananas"? Do you mean it doesn't load the package and you get errors from unevaluated expressions? Try using Get["OtherPackage"] instead of <<. $\endgroup$ – ZachB Oct 1 '15 at 1:37
  • $\begingroup$ I used the Get["OtherPackage"] but the same thing happens. It's hard to explain what happens: there is an initial output confirming "OtherPackage" was loaded (it seems so), but then it processes the rest of the script faulty and with general stops, complaining about non-invertible matrices and arrays with unequal length, etc which I would interpret as "OtherPackage" not being successfully load... $\endgroup$ – romanovzky Oct 1 '15 at 9:37

Your Answer

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

Browse other questions tagged or ask your own question.