RunProcess

RunProcess["command"]
runs the specified external command, returning information on the outcome.

RunProcess[{"command",arg1,arg2,}]
runs the specified command, with command-line arguments .

RunProcess[command,"prop"]
returns only the specified property.

RunProcess[command,prop,input]
feeds the specified initial input to the command.

DetailsDetails

  • RunProcess blocks until the process it starts has finished.
  • In RunProcess[command,prop,input], input is automatically converted to a string using ToString. The same is true for the in RunProcess[{command,arg1,},].
  • Typical possible properties to return include:
  • "ExitCode"the exit code for the process
    "StandardOutput"data sent to standard output, as a string
    "StandardError"data send to standard error, as a string
    Allan association of all properties (default)
  • RunProcess has the following options:
  • ProcessDirectoryInheritedinitial working directory
    ProcessEnvironmentInheritedenvironment variables to supply
  • By default, the subprocess will inherit its process directory and environment variables from the Wolfram Engine.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Run the command-line console and a couple of commands inside it, then quit it:

In[1]:=
Click for copyable input
Out[1]=

Run the same program with the same input, but retrieve only its standard output:

In[1]:=
Click for copyable input
Out[1]=

Run a program and check only the exit code:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2014
(10.0)