Questions tagged [scripting]

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

4
votes
1answer
47 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 ...
1
vote
1answer
40 views

Removing Extra Points When Finding an Audio Envelope

I am trying to reproduce Camtasia's way of displaying audio signals which is a strictly positive envelope of the audio signal and very easy for me to identify some sounds visually. These are displays ...
0
votes
0answers
41 views

Testing if a function input is an integer

I am wondering why code like digitback[n_Integer] := Framed[Reverse[IntegerDigits[n]]] can check if the input for the function is an integer (this is the ...
6
votes
1answer
91 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 ...
0
votes
0answers
56 views

WolframScript Causing Gibberish Characters When Printing to Console

Placing the following in ./file.wls: e1 = a (x + I y) E^(I θ) ComplexExpand[e1] and running ...
0
votes
0answers
17 views

Running CloudDeploy from WolframScript

The following $ wolframscript -cloud -code "CloudDeploy[Manipulate[n, {n, 1, 100}]]" yields ...
2
votes
0answers
29 views

Querying WolframAlpha from WolframScript

Is it possible to query WolframAlpha from a wolframscript query? The following yields $Failed: ...
3
votes
1answer
101 views

Creating flags to use with wolframscript?

Is it possible to create flags to pass arguments into a script with wolframscript? I am trying to pass multiple variables that correlate to specific keys. For example, wolframscript -script ...
1
vote
2answers
173 views

Mathematica code in fortran [closed]

I have an integral in which the integrand is a combination of ratio of modified bessel function of second kind. I am able to find the solution of this integral with mathematica Nintegrate module with ...
1
vote
1answer
64 views

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

Let's say I have a group of X's characters that I want to cut down. I want to use a method similar to 'find-and-replace-all' tool from Word, which takes an amount of X's each time, deletes them, and ...
9
votes
1answer
164 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 ...
1
vote
1answer
44 views

Getting a link to a Wolfram Cloud notebook from a WolframScript query?

Is there a way to make something like wolframscript -code 'Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}]' -cloud spin up a new Wolfram Online notebook with the ...
1
vote
0answers
40 views

Getting wolframscript to print out error messages?

While running a .wls file from the command line using wolframscript, is there a way to get the error messages printed to the command line?
4
votes
1answer
67 views

Context leak in Wolfram Script?

hello.nb SetOptions[EvaluationNotebook[], CellContext -> Notebook] Print["hello"]; a = 1; Print[a]; Print@Context[] bye.nb ...
0
votes
0answers
21 views

Console Output to file corrupted

When i run WolframScript and write the output of a *.wls to a file and then modified the program slightly, i started getting these more exotic outputs. The function used is NetTrain. Does someone ...
-2
votes
1answer
30 views
1
vote
0answers
43 views

Passing custom options to WolframScript file

I have an example of WolframScript file file.wls with the following contents. ...
1
vote
0answers
16 views

WolframScript fails silently intermittently (but only when connected to internet)

When I execute "wolframscript" from a bash shell repeatedly, it sometimes starts up, and sometimes fails. Failures occur about half of the time. The failure is silent. If I turn wifi off (so that I ...
1
vote
1answer
148 views

Electric Field Plot

I want to show an electric field of several arrangements of point charges in xy-plane. I wrote a routine that plots an electric field of a charge: ...
0
votes
0answers
21 views

String getting modified after exporting to PDF

I create and export the plot: ...
0
votes
0answers
25 views

API is not responding

I am looking at the examples of wolframscript to learn its capabilities and syntax. In one of the examples the following API is considered. ...
0
votes
1answer
57 views

Writing a script that exports results depending on user input

Is there a way to tell Export to hold its arguments and just Export. I tried to use ...
1
vote
1answer
38 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
41 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
42 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
46 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 ...
2
votes
2answers
133 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
4answers
84 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
107 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
189 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
173 views

Another way to calculate frequency from Fourier transform

I have some trouble with calculating frequency after Fourier transform. My code: ...
2
votes
1answer
36 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 (...
3
votes
0answers
64 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
35 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
118 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
56 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
26 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
126 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
113 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
61 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
215 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
184 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
56 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
55 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
156 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
80 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 ...
6
votes
0answers
127 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 ...
3
votes
1answer
235 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 ...