Wolfram Computation Meets Knowledge

Technologies

WolframScript (for the Command Line)

Execute Wolfram Language Code Anywhere

WolframScript enables Wolfram Language code to be run from any terminal, whether or not a Wolfram kernel is available on the system.

With WolframScript, users can decide where and how to run their Wolfram Language code. Along with configurable kernel and cloud settings, WolframScript includes a collection of convenience functions for a wide variety of tasks, including running pure functions with command-line input, calling cloud APIs and exporting data to any format supported by the Wolfram Language. Now you can run code in the Wolfram Cloud with wolframscript -cloud or with #!/usr/bin/env wolframscript -cloud in Unix shell scripts.

Examples

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:

$ wolframscript -cloud -code 2+2
            4

Script files

Create a file to execute Wolfram Language code locally:

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

Create a file to execute Wolfram Language code in the Wolfram Cloud:

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

Create a file that uses a command-line argument:

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

Create a file giving a function whose arguments come from the command line:

file.wls
#!/usr/bin/env wolframscript -function -signature City City
                Print[GeoDistance[#1, #2]]&
$ ./file.wls "Champaign, IL" "Oxford, England"
            Quantity[4010.4812837526256, Miles]
See more examples in the full documentation »

Features

WolframScript introduces a wide variety of command-line interactions to best fit your scripting needs.

Run Code on the Command Line

Code can be passed to WolframScript directly on the command line with the -code argument, allowing the user to immediately display or redirect the output into a file.

Run Code from a File

Code can be run directly from Wolfram Language packages using the -file argument.

Create Executable Scripts

WolframScript can be used as a script interpreter, allowing for scripts to be written with the Unix #! syntax on systems where this is supported.

Run Functions from the Command Line

Pure functions can be defined and executed using data and arguments from the command-line environment, allowing for easy ad-hoc sequential operations.

Simple Interaction with Input Streams

Data streamed into WolframScript is captured into the $ScriptInputString symbol for easy processing of data either all at once or iteratively line by line.

Use Cloud-based Computation

WolframScript is now capable of executing code using the Wolfram Cloud. It can be configured to use either the public Wolfram Cloud or Private Cloud.

Directly Access Cloud APIs

WolframScript is capable of parsing argument input and sending data directly to APIs hosted either in the Wolfram Cloud or Private Cloud using APIFunction.

Rich Export Formats

WolframScript is capable of converting and exporting its data to any export format supported by the Wolfram Language using the -export argument.

Now With Windows Support

WolframScript is now fully featured in Windows with support for the basic Windows command shell, MSYS or Cygwin.

Automatic Kernel Detection

WolframScript will automatically select the latest Wolfram kernel installed on the user's system (Windows, Mac).

Technical Information

  • WolframScript supports x86 and x64 systems running Windows, Mac or Linux. ARM support is available on Linux.
  • A Wolfram Cloud account is required in order to utilize the cloud-based features of WolframScript.
  • Using WolframScript on different platforms requires different escaping semantics.
  • WolframScript is distributed with Version 11 of the Wolfram Language and above.