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.

4
votes
2answers
52 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
76 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....
2
votes
1answer
123 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
129 views

Another way to calculate frequency from Fourier transform

I have some trouble with calculating frequency after Fourier transform. My code: ...
2
votes
1answer
30 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
50 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
28 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
54 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
43 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
64 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
103 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
42 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
87 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
148 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
50 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
50 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
96 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
45 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
93 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
151 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
69 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
117 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
93 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
99 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
107 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
71 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
79 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
427 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
431 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
325 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
56 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
342 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
47 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
44 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
99 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
223 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
183 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
74 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
85 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 ...
1
vote
1answer
205 views

Why does Mathematica WolframScript get file fail? [closed]

I use Mathematica 11 and create a project containing two files: a package file named MyPackage.m and the other named run.m. The ...
0
votes
0answers
22 views

Getting input file name and directory with wolframscript [duplicate]

I have the following script: $ cat mathtest.m pardir=DirectoryName @ $InputFileName; Print["test parent dir: ", pardir] If I run it like this, I get: ...
2
votes
0answers
104 views

Wolfram Script as a Scheduled Task on Windows Server

I have a wolfram script file (.wl) that processes a csv file and generates a PDF output. I have written a PowerShell Script which checks for new input data files and runs the wolfram script file over ...
0
votes
0answers
321 views
5
votes
1answer
149 views

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

With the 10.4 version of WolframScript, I could run something like ...
1
vote
1answer
48 views

Turning a NB into a Repeatable Script?

I am interested in "automating" the following notebook file so that I can execute it many times to generate many plots. ...