Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [scripting]

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

0
votes
1answer
25 views

Disable Message Windows

Is there any way to disable Mathematica's internal popup windows, such as "Why the beep?" Cannot seem to find any documentation on the ability to turn it off, but need it turned off to write some ...
2
votes
1answer
36 views

How to export parameters in a text file?

I have some parameters defined in my notebook as, for example, a=1; b=2; c=3; and I want to export these parameters to a .txt file in which I have the following ...
0
votes
0answers
34 views

Wolframscript does not terminate

I have a little package and a script. The portion in the script is copied from the Mathematica notebook and finishes just fine within half a minute on my laptop. Now I want to run this as a script on ...
1
vote
0answers
40 views

Privilege violation for file or directory

hopefully somebody can help me out with the following; I have a mathematica .wl script which uses ParallelTable; When I run this locally (laptop) it works ...
3
votes
0answers
35 views

How to automatic close the Command window when a wolframescript is end of operation?

I have generated a .wls file in Mathematica 11. A command window will appear when the .wls runs, but the command window will ...
1
vote
2answers
71 views

Passing arguments into a script in WolframScript

According to https://reference.wolfram.com/language/ref/program/wolframscript.html i can pass arguments to a file containing wolframscript. But i cannot find a way to actually use passed arguments. <...
4
votes
2answers
55 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 ...
0
votes
1answer
97 views

Animate particle's trajectory

Does anyone know how to animate the trajectory of a particle, but make sure before the particle reaching a certain spot, there's nothing. I mean I want to make an animation that look like https://en....
3
votes
3answers
180 views

How can I test my machine learning model on a machine with no Mathematica?

I need to test my machine learning models that I’ve built using Predict on 100,000 observations. The problem is that the machine where the testing is done doesn’t ...
1
vote
3answers
164 views

Another way to calculate frequency from Fourier transform

I have some trouble with calculating frequency after Fourier transform. My code: ...
2
votes
1answer
34 views

How to use InputForm for printed and output expressions in console mode

When I run Mathematica in console mode (math.exe/wolfram.exe) without a GUI frontend, then printed and output expressions are (...
2
votes
0answers
52 views

Not getting any output from mathematica script

I am completely new, so this question may be trivial, but I can't find any answers in the Wolfram documentation. I am playing around with scripting in Mathematica, but I cannot seem to get any type ...
2
votes
0answers
31 views

How to have batch script wait for free licence before executing?

Is there any way to make a mathematica script (that I'm running in batch using HTCondor) wait until there is an available licence before executing? Several of my scripts are returning nothing but ...
2
votes
0answers
79 views

Convert .nb to .m with a single script or command line in linux [duplicate]

I have some scripts in ".nb" format and I am more used to launch them in Linux command line in Linux but I need them in ".m" format. Usually I open the ".nb" script with the Mathematica Notebook and ...
4
votes
0answers
48 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 ...
0
votes
1answer
54 views

Beginner's Problem [closed]

Suppose I have an expression like $7zz_1+5zz_1-\frac{7z_1}{y}+\frac{5z_1}{l}$. How do I convert it to $7(z-\frac{1}{y})z_1+5(z+\frac{1}{l})z_1$. Please help.
2
votes
1answer
23 views

RunProcess returns a confusing error message when using ProcessDirectory options

Here is one way to find the names of the files in one's home directory: FileNames["*", "~"] (* { "~/.account", "~/Applications", "~/.bash_sessions", ... } *) ...
3
votes
0answers
90 views

Command line arguments to wolframscript interact strangely with -file option

In order to avoid script-defined command-line arguments clashing with existing arguments to wolframscript, it appears you are supposed to use the ...
5
votes
3answers
110 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 ...
3
votes
0answers
48 views

Using an existing local kernel when launching from command line

I am trying to setup a web interface to a couple of Mathematica scripts, which in itself is quite simple: ...
3
votes
1answer
136 views

How to execute a Mathematica notebook in a shell script to produce plots/graphics [duplicate]

I want to produce some plots/graphics for a large amount of data on a computing cluster in a high-throughput way. I'd like to do this by piping results through Mathematica where I'd apply some post-...
7
votes
0answers
156 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 ...
-2
votes
2answers
52 views

How do I plot the PDF of a Mixed distribution with the following parameters?

m = FindDistribution[d2, 1] MixtureDistribution[{0.719504,0.280496}, {NormalDistribution[-4.85601, 2.63207], NormalDistribution[-2.7934, 0.845561]}] I need to ...
3
votes
0answers
53 views

Launching kernels… freezes

I'm running a Mathematica script on a remote machine (via ssh connection). I log on the machine and I execute math -script algorithm.m and this message appears ...
1
vote
1answer
129 views

How do I create 3d plot of a sigmoid or linear function in 3d?

How can i plot a 2d function (y=x) in 3d with decaying z values. Something like this One side of the curve can be flat at max too,like the right side, I am mostly interested in decaying values ...
0
votes
0answers
63 views

Save output of Mathematica batch job to file

bsub "math -script input.m > output.out" runs the Mathematica command in input.m as a batch job and should print the output ...
3
votes
0answers
106 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 ...
2
votes
1answer
182 views

Wolframscript output not evaluated

Edit: I made a stupid mistake, see answer below Whenever I execute wolframscript code from the command line, my Print[] output ...
4
votes
0answers
58 views

Processor Detection Problem with Mathematica in Linux command-line

Here is the problem, there are two ways to launch Mathematica in Linux: Double click a notebook file in Desktop (GUI mode). It gives: $ProcessorCount (* 4 *) ...
0
votes
0answers
31 views

what does & mean in mathematica? what's its usage? [duplicate]

when I type 1 & 8 I get this: 8 (1 &) why do I get this output? and when I type f[#,a]&x, the output is x (f[#1,a]&)
1
vote
1answer
74 views

RunProcess and Ghostscript problem

I have created a pdf from two plots with GraphicsColumn and now I need to get rid of the extra whitespace on the sides. Don't use ...
1
vote
1answer
143 views

Accessing the front end from wolframscript

I am trying to write a wolframscript script to produce PDF versions of notebooks. I understand that to do this, I have to open the notebook, and only a frontend can open a notebook. However, depending ...
0
votes
2answers
95 views

My code for iterating GPS receiver location doesn't work [closed]

This is a line of code i've utilised in order to iterate for GPS location i've tried to base it off this guys code, https://math.stackexchange.com/questions/1445808/newton-raphson-method-in-gps?...
0
votes
0answers
119 views

Save Notebook as Wolfram Script?

It is possible to automatically save a notebook as a Package (see https://mathematica.stackexchange.com/a/1370/5340). The generated package file only contains the cells marked as Code. This has the ...
1
vote
3answers
129 views

How to solve differential equations in for loop in mathematica?

I have a system of differential equation for which I want analytical solution. Let say my equations are - x'[t] - X[[i]]*y[t] == 0, y'[t] + X[[i]]*x[t] == 0 ...
1
vote
0answers
39 views

RandomVariate without zero

I want to get 10 random numbers drawn from a Poisson distribution with mean 1. But I do not want to include 0 in this. When I do ...
1
vote
0answers
76 views

Parallel execution in $2 \times 4$ kernels

Let's say I have 8 CPUs available on a single node. I want to run two instances of the same script (from command line with wolframscript in args > out &) on that node in parallel. Is there a way ...
1
vote
0answers
88 views

Programmatically generate wolfram language script (.wls) file from notebook (.nb) files [duplicate]

For a better integration with git version control, I'm looking for a way to programmatically generate .wls file from existing notebook .nb files, given the path to a specific notebook file ...
7
votes
2answers
490 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: ...
2
votes
1answer
523 views

CMD method to convert .nb file into .m file

.nb file consists of the boxes, and the .m file is a pure text file, what can help to share on GitHub. Of course, we can open a <...
2
votes
2answers
361 views

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

This is basically Analogue of NotebookDirectory[] for scripts (to get the directory path of my script.m)? or Write a mathematica script that returns the absolute path to its directory or How to set ...
4
votes
0answers
57 views

Feedback for my autosave-script

last evening Mathematica crashed and hours of work were gone, because I forgot to save my notebook. During homework today I just pressed Ctrl+S every few minutes, to make sure that I don't loose my ...
5
votes
2answers
367 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 ...
0
votes
0answers
48 views

Arg function very slow

In this thread Argument of complex number with a variable I asked the question how to get the phase of a complex expression with one single real and positive variable. In principle this is solved but ...
1
vote
1answer
52 views

Argument of complex number with a variable

I want to evaluate the following expression Arg[E^((0. + 6.66667*10^-12 I) omega)/(4 - E^((0. + 2.*10^-11 I) omega))] where the variable omega is real and ...
4
votes
0answers
101 views

Wrapper for mathematica code with GUI

I have a code written in Mathematica. What I am trying to do is to write a wrapper (say using Python) that will take user input for the Mathematica code, run the code, and create output. I do not ...
0
votes
0answers
266 views

Normalize a complex matrix

I have a complex matrix say, M={{a+bi,c,c,d},{0,a-di,c,d},{d,c,a-di,0},{d,c,c,a+bi}}; Normalize[M] I attempted to normalize this symbolic matrix with Mathematica ...
5
votes
0answers
212 views

WL and WLS textformatting

I am really happy with the new wls (Wolfram Language Script) files. I somewhat abuse the file format, I use them instead of the regular Notebook files. The advantage is that they do not store the ...
0
votes
1answer
77 views

Script not executed from command line on window

I have a simple test.m file: (*--- file test.m -------*) Print["Testing"] Integrate[Sin[x],x] (*---- end of file ------*) And I executed it in command line (...
0
votes
0answers
91 views

Keep kernels alive in parallel evaluations of several scripts

I have written a parallel script file that after initializing the kernels it puts the result of some computation in a file. I provide some external parameters to the script. I would like to run the ...