We’re rewarding the question askers & reputations are being recalculated! Read more.

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
43
votes
1answer
2k 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 ...
34
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 ...
18
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: ...
17
votes
3answers
8k 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
1answer
957 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 ...
16
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 ...
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?
15
votes
2answers
900 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 ...
15
votes
1answer
740 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 ...
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: ...
13
votes
2answers
9k 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 ...
12
votes
2answers
797 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, ...
11
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 ...
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
893 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
366 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
896 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
869 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
2answers
8k 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
734 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
1answer
759 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 ...
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
116 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
310 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 ...
7
votes
1answer
616 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
208 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 ...
6
votes
3answers
268 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
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
101 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
122 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 ...
6
votes
3answers
385 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
2answers
298 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
526 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
491 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
375 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
165 views

Passing UTF-8 to wolframscript on the command line

I am trying to use Unicode input to wolframscript -c, like so: $ ./wolframscript -c '1/∞' â^(-1) The source of this behavior ...
5
votes
1answer
566 views

Can't run Bash scripts from within Mathematica 10.1

I am working on Debian 8 (Jessie) and Mathematica 10.1 (64-bit) Home Edition. I have created a script named curl_fetch.sh. It contains the line: ...
5
votes
4answers
125 views

How to copy a string to the clipboard from a script?

How to copy a string to the clipboard from a script? I want the wolfram script to copy a string to the clipboard. Unfortunately the following script fails to do this. The same code works perfectly ...
5
votes
1answer
1k views

Wolfram language from batch or py

I would like to automate the commands in this website into a batch file, so when the batch file it runs these commands in sequence. http://community.wolfram.com/groups/-/m/t/157461 Do any of you have ...
5
votes
1answer
902 views

Interrupting package evaluation, handling error

I have some packages/scripts that I schedule the execution using Jobs in SQL server. For example, in some of then, I use to create reports and delivery by mail using Mathematica. All done using ...
5
votes
1answer
481 views

Mathematica script - Using front end

I'm running Mathematica on OS X and I want to create an Automator action that converts spreadsheet files. I have written this script: ...
5
votes
1answer
204 views

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

With the 10.4 version of WolframScript, I could run something like ...
5
votes
1answer
1k views

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

I was trying to understand how to use wolframscript (new in Mathematica 11) in a console window on Win 10. I set my Path environment variable to point to the ...
5
votes
2answers
491 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 ...
5
votes
2answers
417 views

Editing Wolfram Language Packages and Scripts

Background I am currently working on a large software development project written in the Wolfram Language and I would like to organize my code in Wolfram Language Packages and Scripts (.wl files. See ...
5
votes
2answers
594 views

How to automate Mathematica scripts? - I [duplicate]

I would like to use the Windows Task Scheduler, or Visual Cron, to start a Mathematica notebook or .m file to do some system maintenance tasks: copy files from one place to another, etc. How do I set ...
5
votes
1answer
60 views

How do I reliably read from stdin using wolframscript?

I am trying to direct a stream of data to a wls script in a command line environment. Wolframscript provides the ...
5
votes
2answers
243 views

How to prevent a standalone kernel from opening windows?

I am trying to make Mathematica do some plots for me as a part of a script. I have a .m file that basically does Import[] on ...
5
votes
1answer
250 views

Wolfram Script Not Completing when ran as cron job

I have a fairly simple Wolfram script called from within a shell script that I would like to run at certain times. The shell script calls a python script to get some recordings to from GPIO and saves ...