WolframScript Command Options

By Xah Lee. Date: . Last updated: .

What is WolframScript

WolframScript is a command line interface to Wolfram Engine. It lets you run WolframLang code from a terminal.

Wolfram Engine comes with WolframScript bundled.

Start WolframScript in terminal

type wolframscript

WolframScript math 2021-10-22 FYBv
WolframScript math 2021-10-22

Exit WolframScript

Type Exit or Quit.

Run a Code Snippet

-c or -code

wolframscript -code "3+1"

Run a Wolfram Script

-f or -file

wolframscript -file test.wls

Print Last Expression in Script

-print

# run a file and print last expression
wolframscript -file test.wls -print

Print All Expressions in Script

-print all

# run a file and print all expressions
wolframscript -file test.wls -print all

Print Version

-version

Get help for options

-h or -help

wolframscript -h

All Options

-h, -help 🔶 Print help text.

-c, -code WL 🔶 Give Wolfram Language code to execute.

-f, -file PATH 🔶 Give a file containing Wolfram Language code to execute.

-a, -api URL|UUID 🔶 Use an API at the specified URL, or coming from a cloud or local object with the specified UUID.
 Provide arguments in the form 'key=value' following '-args'.

-fun, -function WL 🔶 Use a function whose arguments are the strings given using '-args' interpreted as the types given using '-signature'

-o, -cloud [CLOUDBASE] 🔶 Execute code in the cloud, using the specified cloud base. By default, cloud base is https://wolframcloud.com

-l, -local [KERNELPATH] 🔶 Execute code locally, using the specified path to the Wolfram Engine kernel. By default, KernelPath uses the most recent version of the Wolfram Language found on the local system.

--, -args ARGS... 🔶 Used with '-api' or '-function' to provide arguments.

-s, -signature TYPE... 🔶 Used with '-function' and '-args' to specify interpreter types for provided arguments.

-v, -verbose 🔶 Print additional information during execution.

-activate 🔶 Activate the Wolfram Engine through the cloud or with a key.

-entitlement ID 🔶 Activate the Wolfram Engine using on-demand licensing with the given license entitlement ID.

-authenticate [ID PASS] 🔶 Authenticate with the cloud, specifying a particular Wolfram ID and password, and prompting if they are not given. Different authentication can be specified for different clouds.

-disconnect 🔶 Disconnect from the cloud, removing authentication information.

-configure [KEY=VAL...] 🔶 Configure WolframScript by specifying values for particular configuration variable keys. If no keys are given, this prints the current configuration.

-version 🔶 Print version of WolframScript.

-username USERNAME 🔶 Give username for authentication.

-password PASSWORD 🔶 Give password for authentication.

-permissionskey KEY 🔶 Give a permissions key used to authorize access to a cloud deployed API.

-k, -noverifypeer 🔶 Disable peer certificate verification when interacting with the cloud.

-timeout SECONDS [VALUE] 🔶 Specify the number of seconds to allow for execution. Return value if time is exceeded.

-charset ENCODING 🔶 Use encoding for output. Encodings can be None to output raw bytes, or any entry in $CharacterEncodings except "Unicode". The default is to infer the value from the terminal's language settings.

-format TYPE 🔶 Specify the format in which to give output. Any format understood by Export can be used.

-print [all] 🔶 When running a script, print the result from executing the last line of the script, or each line if all is given.

-linewise 🔶 Execute code on each line of standard input that is read.

-script ARGS... 🔶 Counterpart to wolfram -script, additionally sets up $ScriptCommandLine.
vidthumb RwtC2ldiekA

Reference

wolframscript

WolframScript and Shell Scripting