Run

Run["command"]

runs command as an external operating system command, returning the exit code obtained.

Details

  • For any expression expr, Run[expr] runs the string corresponding to OutputForm[expr] as an external operating system command.
  • Run returns an integer that corresponds, when possible, to the exit code for the command returned by the operating system.
  • In a notebook interface, the command executed by Run cannot take interactive input, and its textual output will not be displayed.
  • In a terminal interface, the command executed by Run can display text and take standard input from the terminal.
  • In a terminal interface, the input line !command will execute an external command.

Examples

open allclose all

Basic Examples  (1)

Create a temporary file:

In[1]:=
Click for copyable input

Insert text into the file; a zero exit code indicates success:

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

Show the contents of the file:

In[3]:=
Click for copyable input

Delete the temporary file:

In[4]:=
Click for copyable input

Scope  (1)

See Also

RunThrough  RunProcess  RemoteRun  Put

Tutorials

Introduced in 1988
(1.0)