A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://reference.wolfram.com/language/ref/program/wolframscript.html below:

WolframScript—Wolfram Documentation

WOLFRAM Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

WolframConsulting.com

NAME

wolframscript command-line script interpreter for the Wolfram Language

SYNOPSIS

wolframscript -code code [-cloud [cloudbase] | -local [kernelpath] | -wstpserver [wstpserverbase]] [arg1 ]

wolframscript -file file|url [-cloud [cloudbase] | -local [kernelpath] | -wstpserver [wstpserverbase]] [arg1 ]

wolframscript -api url|uuid|file [-cloud [cloudbase] | -local [kernelpath] | -wstpserver [wstpserverbase]] [-args key=value ]

wolframscript -function code [-cloud [cloudbase] | -local [-kernelpath] | -wstpserver [wstpserverbase]] [-signature type ] [-args values ]

DESCRIPTION

WolframScript runs Wolfram Language code, functions and deployed APIs locally, in the cloud or on WSTPServer, allowing input from standard input, command-line arguments, files, URLs, etc.

OPTIONS DETAILS EXAMPLES Code from Command Line

Evaluate the Wolfram Language code 2+2 on a local Wolfram Engine:

$ wolframscript -code 2+2
4

Evaluate the Wolfram Language code 2+2 in the Wolfram Cloud, prompting for authentication as needed:

$ wolframscript -cloud -code 2+2
4

If a running WSTPServer is available on the network, evaluate the Wolfram Language code 2+2 in that WSTPServer:

$ wolframscript -wstpserver -code 2+2
4

Evaluate Wolfram Language code locally, escaping input for a Unix-style shell:

$ wolframscript -code 'StringReverse["hello"]'
olleh

Evaluate Wolfram Language code locally, escaping input for the Windows cmd.exe shell:

> wolframscript -code StringReverse[\"hello\"]
olleh

Evaluate code and put the results in a file:

$ wolframscript -code "Graphics3D[Sphere[ ]]" -format PNG > file.png
Code from File

Evaluate Wolfram Language code from a file, returning the last result generated:

$ wolframscript -file test.wl
12345

Take code from a local file, but run it in the cloud:

$ wolframscript -cloud -file test.wl
12345
Script Files

A file set up to execute Wolfram Language code locally:

file.wls
#!/usr/bin/env wolframscript
Print[2+2]
$ ./file.wls
4

A file to execute Wolfram Language code in the Wolfram Cloud in a Unix-style shell:

file.wls
#!/usr/bin/env wolframscript -cloud
Print[2+2]
$ ./file.wls
4

A file to execute Wolfram Language code in a running WSTPServer in a Unix-style shell:

file.wls
#!/usr/bin/env wolframscript -wstpserver
Print[2+2]
$ ./file.wls
4

A file that uses a command-line argument:

file.wls
#!/usr/bin/env wolframscript
Print[ToExpression[$ScriptCommandLine[[2]]]^2]
$ ./file.wls 5
25

A file giving a function whose arguments come from the command line in a Unix-style shell:

file.wls
#!/usr/bin/env wolframscript -function -signature City City
GeoDistance[#1, #2]&
$ ./file.wls "New York" London
Quantity[3453.7070027090986, Miles]
Interactive Operation

Run the Wolfram Language in an interactive REPL:

$ wolframscript
Wolfram 14.3.0 Kernel for Mac OS X ARM (64‐bit)
Copyright 1988-2025 Wolfram Research, Inc.

In[1]:= 2+2

Out[1]= 4

In[2]:= 

Run the Wolfram Language in an interactive REPL using a running WSTPServer:

$ wolframscript -wstpserver

In[1]:= 2+2

Out[1]= 4

In[2]:= 
APIs

Run a cloud API:

$ wolframscript -api https://wolfr.am/bNvKWq2U -args x=1 y=2
3

Get the code for an API from the cloud, but run the API locally:

$ wolframscript -api https://wolfr.am/bNvKWq2U -local -args x=1 y=2
3
Additional Examples

Sign in to a different cloud account:

$ wolframscript -authenticate
Enter WolframID: example-user@wolfram.com
Password:

Success. Saving connection data.

Provide credentials without using a prompt:

$ wolframscript -username example-user@wolfram.com -password XXXXXX
Success. Saving connection data.

Disconnect from the cloud, clearing connection information:

$ wolframscript -disconnect

Reverse the string on each line of an input file, writing the result to another file in a Unix-style shell:

$ wolframscript -code 'StringReverse[$ScriptInputString]' -linewise < file1 > file2 

Reverse the string on each line of an input file, writing the result to another file using cmd.exe on Windows:

> wolframscript -code StringReverse[$ScriptInputString] -linewise < file1 > file2 

Limit an evaluation using timeout:

$ wolframscript -code "Do[Print[i];Pause[1], {i,10}]" -timeout 3
1
2
3
$TimedOut

Use a specific character set for output in a Unix-style shell:

$ wolframscript -code 'Alphabet["Greek"]' -charset UTF8
{α, β, γ, δ, ε, ζ, η, θ, ι, κ, λ, μ, ν, ξ, ο, π, ρ, σ, τ, υ, φ, χ, ψ, ω}

Use a specific character set for output using cmd.exe on Windows:

> wolframscript -code Alphabet[\"Greek\"] -charset UTF8
{α, β, γ, δ, ε, ζ, η, θ, ι, κ, λ, μ, ν, ξ, ο, π, ρ, σ, τ, υ, φ, χ, ψ, ω}

Use the options -print and -format in a script to generate an image in a Unix-style shell:

file.wls
#!/usr/bin/env wolframscript -print -format PNG
ListLinePlot[RandomFunction[WienerProcess[],{0,10,0.01},10]]
$ ./file.wls > plot.png

Print each result generated during the execution of a script using the -print All option in a Unix-style shell:

file.wls
#!/usr/bin/env wolframscript -print All
"Using -print All print will each result"
a = 2+2; (* This line won't print because the ; suppresses output *)
a
$ ./file.wls
Using -print All will each result
4

Create an API protected by a PermissionsKey, and pass the key to WolframScript to access it:

$ wolframscript -api 83aa0bc2-8e0c-4ef6-b314-48e0bf283196 -args n=5 -permissionskey thekey
25

Check the version of WolframScript:

$ wolframscript -version
WolframScript 1.2.0 for MacOSX-x86-64

Configure to use a particular WolframEngine:

$ wolframscript -config WOLFRAMSCRIPT_KERNELPATH=/Applications/Mathematica.app/MacOS/WolframKernel
Configured:WOLFRAMSCRIPT_KERNELPATH=/Applications/Mathematica.app/MacOS/WolframKernel
FILES

Default configuration file:

Default authentication folder:

WOLFRAM LANGUAGE VARIABLES

The following variables are set when WolframScript begins execution.

$CommandLine A list of strings giving the complete command line used.

$ScriptCommandLine A list of command-line arguments intended for the script being run. These come after options given with -option.

$ScriptInputString A string giving input supplied to the script through standard input. The option -linewise loads this variable with one line of standard input for each iteration of the script.

ENVIRONMENT VARIABLES

WOLFRAMSCRIPT_AUTHENTICATIONPATH The folder storing authentication information.

WOLFRAMSCRIPT_CONFIGURATIONPATH The file storing persistent configuration information.

WOLFRAMSCRIPT_CLOUDBASE The default cloud base to use in WolframScript.

WOLFRAMSCRIPT_ENTITLEMENTID An on-demand license entitlement ID to activate the kernel using.

WOLFRAMSCRIPT_KERNELPATH The path to the default local Wolfram Engine kernel executable.

WSTPSERVER PROFILE VARIABLES

WSTPSERVER The WSTPServer base of the WSTPServer that manages the desired kernel.

POOL The name of the pool of the desired kernel.

KERNELPATH The kernel path of the desired kernel.

KEEPALIVE The Boolean setting on whether to close the kernel on unbridge of the desired kernel.

RESERVEONDISCONNECT The Boolean setting on whether to reserve the kernel on unbridge of the desired kernel.

If a profile variable is not provided, WolframScript will not select for a kernel managed by WSTPServer according to that profile variable.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4