({{, (RefLink[RunProcess, paclet:ref/RunProcess])["command"] 
runs the specified external command, returning information on the outcome.}, {, (RefLink[RunProcess, paclet:ref/RunProcess])[{"command",(Subscript[arg, 1]),(Subscript[arg, 2]),…}]
runs the specified command, with command-line arguments (Subscript[arg, i]).}, {, (RefLink[RunProcess, paclet:ref/RunProcess])[command,"prop"]
returns only the specified property.}, {, (RefLink[RunProcess, paclet:ref/RunProcess])[command,prop,input]
feeds the specified initial input to the command.}})

OpenersNotesSection(Spacer1)Details

(RefLink[RunProcess, paclet:ref/RunProcess]) blocks until the process it starts has finished.

In (RefLink[RunProcess, paclet:ref/RunProcess])[command,prop,input], input is automatically converted to a string using (RefLink[ToString, paclet:ref/ToString]). The same is true for the (Subscript[arg, i]) in (RefLink[RunProcess, paclet:ref/RunProcess])[{command,(Subscript[arg, 1]),…},…].

Typical possible properties to return include:

(RefLink[RunProcess, paclet:ref/RunProcess]) has the following options:

By default, the subprocess will inherit its process directory and environment variables from the Wolfram Engine.

OpenersPrimaryExamplesSection(Spacer1)Examples  (10)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Run a simple external command:

RunProcess["date"]

Run a command, and get back only what it writes to the standard output channel:

RunProcess["date","StandardOutput"]

Give a command-line option to the function:

RunProcess[{"date","-u"}]

Equivalent command on Windows:

RunProcess[{"cmd","/c","\"date /t\""}]

Run a command, and get back only its exit code:

RunProcess["date","ExitCode"]

RunProcess["echo",All,"hello there"]

OpenersExampleSection1(Spacer1)Scope  (2)

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

RunProcess[$SystemShell,All,"echo example line 1
echo example line 2
exit
"]

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

RunProcess[$SystemShell,"StandardOutput","echo example line 1
echo example line 2
exit
"]

OpenersExampleSection3(Spacer1)Possible Issues  (4)

The right way to call (RefLink[RunProcess, paclet:ref/RunProcess]) for a program plus its arguments is using a list:

optionC=If[StringFreeQ[$System,"Windows"],"-c","/c"];

RunProcess[{$SystemShell,optionC,"echo example line"}]

Calling (RefLink[RunProcess, paclet:ref/RunProcess]) with the command and arguments in a single string does not work:

RunProcess[StringJoin[{$SystemShell," "<>optionC<>" \"echo example line\""}]]

Also, calling (RefLink[RunProcess, paclet:ref/RunProcess]) with the program arguments as arguments for (RefLink[RunProcess, paclet:ref/RunProcess]) is not allowed:

RunProcess[$SystemShell,optionC,"echo example line"]

Special symbols like ~ and * are not converted using shell expansion because (RefLink[RunProcess, paclet:ref/RunProcess]) skips the shell:

RunProcess[{"diff","~/file1","~/file2"}]

Shell commands like dir and echo cannot be called directly on Windows because they are not binaries (however, they are binaries on Unix systems):

RunProcess[{"echo","this line only works on Unix systems like MacOS and Linux"}]

Some commands might need to be called using absolute paths:

RunProcess[{"/bin/echo","example"}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ExternalEvaluate, paclet:ref/ExternalEvaluate])  ▪  (RefLink[RunThrough, paclet:ref/RunThrough])  ▪  (RefLink[Run, paclet:ref/Run])  ▪  (RefLink[StartProcess, paclet:ref/StartProcess])  ▪  (RefLink[Install, paclet:ref/Install])  ▪  (RefLink[Put, paclet:ref/Put])  ▪  (RefLink[Get, paclet:ref/Get])  ▪  (RefLink[Import, paclet:ref/Import])  ▪  (RefLink[$SystemShell, paclet:ref/$SystemShell])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Calling External Programs, paclet:guide/CallingExternalPrograms])}, {▪(RefLinkPlain[External Language Interfaces, paclet:guide/ExternalLanguageInterfaces])}, {▪(RefLinkPlain[Direct Control of External Processes, paclet:guide/DirectControlOfExternalProcesses])}, {▪(RefLinkPlain[External Operations, paclet:guide/ExternalOperations])}})}})