Questions tagged [scripting]

For questions about Wolfram Language Scripts (formerly known as Mathematica Script), or running the kernel without direct user interaction.

Filter by
Sorted by
Tagged with
46
votes
1answer
3k views

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

I generally consider Mma documentation very good. However, it is startlingly difficult to find useful information on running Mma batch scripts, especially on Windows. So ... just what would I enter ...
44
votes
2answers
3k views

Running Mathematica on Docker

I didn't find any information on the net about running Mathematica math/Wolfram Engine (wolframscript) in a Docker Container. Is ...
35
votes
1answer
1k views

Why are all the lines commented when I create a Mathematica script?

When I created a Mathematica script, I found that all my lines were commented out (when opened with vi or gedit or any other ...
22
votes
3answers
2k views

Reading from STDIN, or: how to pipe data into Mathematica

Today I tried using Mathematica's plotting capabilities to display the output of a C++ program. This made me wonder whether it is possible to somehow tell a Mathematica script to read from STDIN and ...
20
votes
4answers
5k views

Mathematica script - passing command line arguments

When using Mathematica script #!/usr/local/bin/MathematicaScript -script Print[$ScriptCommandLine] and running it with some arguments: ...
19
votes
1answer
1k views

Difference between “wolframscript -f” and “wolframscript -script”

In Mathematica 11, there is new wolframscript.exe According to help wolframscript.exe -h -f [ -file ] arg---------Run a ...
18
votes
2answers
14k views

Running Mathematica Notebook files in command mode

The question is, how can I run a .nb file in the kernel mode of Mathematica? I am not an expert in Mathematica, but one of our users who use this program says that ...
18
votes
3answers
10k views

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

Suppose I have a Mathematica script called test.m. There at least 4 ways to run this from the terminal: ...
17
votes
2answers
4k views

Printing a string in a Mathematica script

Here's a simple script saved in the file hello #!/usr/local/bin/MathematicaScript -script Print["Hello world"] I can then run ...
17
votes
1answer
1k views

Evaluating a notebook programmatically with -ne

I am running Mathematica 10.2 on an Ubuntu workstation. I would like to be able to evaluate a notebook through the command line, and save its final state so that I can launch evaluation remotely ...
16
votes
1answer
2k views

Scheduling Mathematica scripts to run from a command line [duplicate]

I want to run Mathematica "jobs" on a daily/weekly basis to do system maintenance and as part of daily processing operations. What is the best way to do this?
16
votes
1answer
179 views

How to create a CLI for Wolfram language scripts?

Former question: How to use wolframscript to develop flexible command-line tools? I am currently changing a notebook into a wolframscript for a "production" environment, where I plan to ...
15
votes
2answers
1k views

Line by line processing with a WolframScript

I am having some difficulty understanding the correct syntax to enable a line by line processing of a file using a WolframScript. What I would like to do to mimic this simple python pipe in ...
13
votes
3answers
1k views

Why doesn't my script work when I redirect stdout?

I'm using Mathematica Home Edition 9.0.1 on Mac OS X 10.8.2. I have this script: ...
12
votes
2answers
829 views

Simultaneously running the same .m file with different inputs

I have my Mathematica code in a .m file and I run it from the command line with some parameters. I was wondering, if there is no overlap in input and output files, ...
12
votes
3answers
2k views

Windows command line arguments, stdin & stdout

Is it possible to utilize all three: command line arguments, stdin, and stdout all at once in script for Windows? Unix is fairly easy, but I can't get the following to work with Windows. Using the ...
12
votes
1answer
1k views

What is the difference between Wolfram Script and Wolfram Engine?

I don't understand the difference between these products: Wolfram Script Wolfram Engine Would someone help me understand what these are? And how it differs from just using Mathematica in the ...
11
votes
1answer
1k views

Formatting and printing lists with Mathematica scripts

I'm just starting out with Mathematica and I'm using MathematicaScript rather than the GUI. However, I'm having trouble formatting a list when printing it. Suppose ...
11
votes
2answers
920 views

Evaluator option for Mathematica Scripts

I have mathematica with many additional kernels besides Local ( e.g., core1, core2, core3, core4 ... ) added through Kernel Configuration Options. I have been running multiple copies of a simulation (...
10
votes
1answer
1k views

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

Is there a way to get the script directory from inside a Mathematica script? I want a function analogue to NotebookDirectory[] (which doesn't work for scripts). Is ...
10
votes
1answer
971 views

How does one use the free Wolfram Engine for developers on Linux?

I just downloaded wolframscript on Linux. Downloading the "free wolfram engine for developers" gives me a ...
9
votes
1answer
988 views

Launch a specific notebook automatically when Mathematica starts

I run Mathematica on an iMac running OS X 10.6.8. I have set the OS's "Launch Items" to include Mathematica so that the application opens when the computer boots. Now I want to go further and ...
9
votes
1answer
903 views

Mathematica scripting on Microsoft Windows

Is it possible to use Mathematica (or the Mathematica kernel) to interact with Microsoft Windows, much like any macro-based scripting language that controls the keyboard/mouse, opens/closes programs ...
9
votes
1answer
172 views

Importing Packages to .wls without shadow definitions and context specification

I am trying to import a package that works correctly when I use it in a notebook in a wolframscript .wls. I get a weird shadowing problem, however. Here is a minimal working example ...
9
votes
1answer
366 views

Saving a source file adds (* ::Package:: *) to the first line

I am running Mathematica 9 on a linux machine and I've encountered the following behaviour that I am trying to understand. When I'm editing multiple source (.m) files using mathematica saving adds a ...
9
votes
2answers
9k views

Command line execution of Mathematica notebooks and conversion to .m

Sometimes one may want to execute a notebook via the command line (for example to run it remotely). As far as I know it's not possible to run notebooks directly, but ...
8
votes
2answers
1k views

wolframscript — How to print in color

I want to print to the console in color from a wolframscript. I tried just using a Style: ...
8
votes
0answers
95 views

Detect if running in a script

Is there a reliable way to detect if the current code is running within a script? Note that there are multiple ways to run a script, such as ...
7
votes
1answer
3k views

Running a shell script within Mathematica

The title pretty much explains it and I have not found something similar already posted. Perhaps I am not searching for the correct title or maybe this is something very basic, but I would appreciate ...
7
votes
1answer
155 views

What is an example of of idiomatic “typed” WolframScript?

I'd like to make my own "typed function" in WolframScript. Suppose the type we desire is called money, and we'd like to make a function called ...
7
votes
1answer
1k views

Installing WolframScript (12) on OSX (Catalina)

I did a clean install of Catalina (OSX 10.15) and Mathematica 12.0 installation was flawless. However I can't install WolframScript which I greatly need. During the installation, after typing my ...
7
votes
3answers
242 views

How to avoid running code when a script is imported as a package?

In Python, the boilerplate line if __name__ == "__main__": defines a code block that should be executed when the code is run as a script, but not when imported as a ...
7
votes
1answer
732 views

Executing Mathematica code via Notepad++

I wonder if there is a way to execute Mathematica code via Notepad++. After some searching on the web, I found that there is a user-defined language that supports Mathematica highlighting, but there ...
7
votes
0answers
272 views

Wolfram Script Console Doesn't Close Automatically on Windows

I'm not exactly sure how Wolfram Scripts are supposed to work. So I wrote a simple one to configure MaTeX for me so that all I have to do is double click it on a system where I've installed ...
7
votes
1answer
457 views

Difference between math and wolframscript

It seems that both math and wolframscript can be used to run Mathematica scripts on the ...
6
votes
3answers
416 views

NotebookEvaluate with InsertResults -> True from the command line

Suppose I have a notebook template.nb like this: and I want to evaluate this notebook from the command line. So I wrote this Mathematica script: ...
6
votes
2answers
154 views

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

I'm experimenting with the Through function. I suspect there is a way to use that function to obtain both the mean and difference of two values. But this doesn't ...
6
votes
3answers
1k views

Temporarily redirect the output of Print[ ] to a second file

I have started using Mathematica to automate file backup operations. The logistics I need make Mathematica a good choice. I am testing and developing the Notebook manually, and ...
6
votes
1answer
153 views

TeXForm doesn't work in wolframscript?

Consider that $ wolframscript -cloud -code 'TeXForm[ (d u)/(d t)]' TeXForm[u/t] yet I don't have a local wolframscript kernel installed. Is this something ...
6
votes
3answers
414 views

Executing Mathematica script from inside SQL Server

Does anyone have experience in calling Mathematica from inside SQL Server to do calculations? For example, how can I make a Procedure that uses Mathematica? Or a job that runs some Mathematica script? ...
6
votes
1answer
311 views

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

With the 10.4 version of WolframScript, I could run something like ...
6
votes
2answers
834 views

How to export graphics to SVG in script executed through cron?

I have a Wolfram script that generates plots, and exports them by evaluating expressions of the form Export["/path/to/some.svg", myPlot]; The script works as ...
6
votes
2answers
383 views

UseFrontEnd is not working the same in version 10.4

I'm using batch files to run Mathematica notebooks (with saved output) but in version 10.4 the functionality has changed. Any ideas how to get it working? I use a batch file to run a .m script which ...
6
votes
2answers
618 views

Why does Mathematica stop when run in the background in command line mode?

If I try to start a Mathematica script in the background from the command line, like this: math -script someFile.m & then the process gets automatically ...
6
votes
1answer
519 views

How to import non-text data from std input in a Mathematica script?

Or maybe a better question is - how can I get a stdin stream? I need to run on Linux. I did look at Reading from STDIN, or: how to pipe data into Mathematica, but ...
6
votes
1answer
144 views

How to create a progress bar using Wolframscript?

I am using Wolfram script with a Mac OS. I have a long while loop dependent on the length of a list. i.e.: ...
6
votes
1answer
195 views

wolframscript creates tons of log files

On Linux, wolframscript seems to create log files in .Mathematica/ApplicationData/ProcessLink/Streams for example: ...
6
votes
1answer
470 views

When I run multiple Mathematica programs from terminal, are they supposed to use different Kernel?

Since I found that when I using notebook interface, I need to assign different kernels to different notebooks (if I want to run them at the same time), I wonder if I run those *.m files from terminal ...
6
votes
0answers
216 views

How to properly call Wolframscript from Python?

I am using Windows 10 x64. If I run the following code in Command Prompt: wolframscript -code ToString[TeXForm["Integrate[Tan[x],x]"]] I get the following ...
6
votes
0answers
48 views

Logging modules in Mathematica?

Is there any logging module or functions or scripts that one can use to store all the information of what happens during executing mathematica program in Wolfram? For example, one might look up log....

1
2 3 4 5 6