36 votes
Accepted

Running Mathematica on Docker

Updated answer with Dockerfile After the release of wolfram engine I thought it is a good time to revisit this old answer and refine it a bit. First install docker on your machine. Follow docker ...
  • 14.4k
23 votes

math.exe vs wolfram.exe vs MathKernel.exe vs WolframKernel.exe (running scripts on Windows)

These two small programs -- math.exe is the same as wolfram.exe, and MathKernel.exe is the ...
  • 25.1k
15 votes

Running Mathematica Notebook files in command mode

It is not a good idea to try to run a notebook in command line mode. Whether or not it is possible, it is just not a good idea because notebooks can only be handled by the Front End, which is not a ...
  • 228k
14 votes

Difference between "wolframscript -f" and "wolframscript -script"

The -script mode is an interface to the wolfram.exe's -script mode, which is a command-line version of Get. It essentially rewrites the command line, launches a kernel using the equivalent command, ...
  • 13.7k
13 votes
Accepted

Can't run Bash scripts from within Mathematica 10.1

(Reposting my comment as an answer) The reason this is happening is that the Mathematica launcher script sets LD_LIBRARY_PATH so that libraries included in the ...
  • 25.1k
13 votes

Controlling point in graphics 3D with locator

You can use ResourceFunction["Locator3D"] as follows: ...
12 votes
Accepted

Proper way to run a Mathematica script (-script vs -run vs MathematicaScript vs <)?

I'm not sure on which operating system you are and whether this makes a difference, but your 4 choice don't do the same. math -run file.m edit: When you change ...
  • 111k
12 votes
Accepted

How to determine the file type of a .m file?

It's somewhat of a meme that WL has a top-level function for everything, but it's kinda true: ...
  • 19.2k
12 votes

Controlling point in graphics 3D with locator

Well, I wrote an interactive Variable Calculus book and, as I don't know a "3D locator", I used mouse events to select and drag points. I learned the code from several posts. Here I share ...
  • 549
11 votes

What is an example of of idiomatic "typed" WolframScript?

Here is an idiom used by many built-in functions to achieve this effect: ...
  • 64k
10 votes
Accepted

Windows command line arguments, stdin & stdout

On Windows, MathKernel.exe launches the kernel running within a window. The standard output is redirected to that window. To avoid this redirection, we must run the kernel as a console application ...
  • 67.5k
9 votes
Accepted

Evaluating a notebook programmatically with -ne

Update a very simple solution to the OP has been given in this very duplicate post: all the outputs (in particular graphics) are then correctly inserted in the evaluated notebook without the need to ...
  • 7,225
9 votes

Running Mathematica on Docker

I created public resources to simplify and automate PlatoManiac's answer for you and all of us: TLDR https://account.wolfram.com/access/wolfram-engine/free?operatingSystem=LINUX ...
9 votes
Accepted

Electric Field Plot

...
  • 35.3k
9 votes

Installing WolframScript (12) on OSX (Catalina)

Download the latest WolframScript installer, which will work on macOS 10.14: The installer from wolfram.com/wolframscript should work – ilian Oct 25 at 16:10
8 votes

Running Mathematica Notebook files in command mode

To replicate the Ctrl+A Enter execution behaviour automatically you can run Solve.nb from a package file, say runSolve.m, containing the code below. While Wolfram Language Scripts are straightforward,...
  • 29.7k
8 votes
Accepted

TeXForm doesn't work in wolframscript?

I didn't check how formatting works in wolframscript but if you force it on your terms then it does not matter: TL;DR: use: $ wolframscript -cloud -code 'ToString @ TeXForm[ (d u)/(d t)]'
  • 133k
8 votes

Importing Packages to .wls without shadow definitions and context specification

Here's a version of the script that works: #!/usr/bin/env wolframscript -print All -run \'Needs[\"ComputerArithmetic`\"]\' Ulp[1000.] This is a limitation of <...
  • 13.7k
8 votes
Accepted

why does wolframscript start an instance of Mathematica frontend?

Certain functionality, most notably rasterizing graphics, is implemented by the front end. In your case it is the JPEG export that triggers this.
  • 228k
7 votes

Analogue of NotebookDirectory[] for scripts (to get the directory path of my script.m)?

DirectoryName @ $InputFileName is the answer, right? And this will work whether you call it from a package or a notebook interface: ...
  • 133k
7 votes

NotebookEvaluate with InsertResults -> True from the command line

This is because the default format type is OutputForm when running on the command line. Add this to the beginning of your script to change it to ...
  • 228k
7 votes
Accepted

How do I get the script directory when running a wolfram script from the command line with wolframscript without -script in Mathematica 11?

Here is a WolframScript that prints its own file name and directory: ...
  • 11.7k
7 votes
Accepted

How to create a find-and-replace code in Mathematica?

You can use StringReplace to define a function to make the replacement and use FixedPointList to get the result of applying the ...
  • 351k
7 votes
Accepted

Destructuring a list containing two items to use it as arguments to a binary function

Here is one way to do what you ask Through[{Mean@*List, Subtract}[1175., 247.]] (* {711., 928.}*) This works by using ...
  • 15.2k
7 votes
Accepted

Stop a script. Just stop it

While you can always abort a running evaluation manually with Command + . (or Ctrl + .), here are several ways to do this in ...
  • 8,458
7 votes

How to find the repeated elements in a vector

DeleteCases requires a pattern, not a function, as second argument: ...
  • 37.9k
6 votes
Accepted

Run mathematica scripts without initializing the kernel every time

This works for running scripts. Print is not supported although the last return value defaults to the stdout. ...
  • 7,489
6 votes

Mathematica on a cluster

Clusters can be significantly different from each other, so I strongly recommend you talk to someone who uses the same system and ask them for help with the details. However, there is one thing that ...
  • 228k
6 votes
Accepted

How to use woframscript (Mathematica 11) on Win 10 console command line?

After looking at my personal use license installation of Mathematica 11, I was able to get wolframscript to run by modifying the the configuration file at ...
  • 1,180
6 votes
Accepted

How to recover WolframScript's former `-run` functionality?

This is an execution mode I don't think we encountered in internal testing for the new wolframscript, the thought being that such processing would occur early in the script, an any needed values would ...
  • 13.7k

Only top scored, non community-wiki answers of a minimum length are eligible