function Deno.run
allow-run
Unstable

Spawns new subprocess. RunOptions must contain at a minimum the opt.cmd, an array of program arguments, the first of which is the binary.

const p = Deno.run({
  cmd: ["curl", "https://example.com"],
});
const status = await p.status();

Subprocess uses same working directory as parent process unless opt.cwd is specified.

Environmental variables from parent process can be cleared using opt.clearEnv. Doesn't guarantee that only opt.env variables are present, as the OS may set environmental variables for processes.

Environmental variables for subprocess can be specified using opt.env mapping.

opt.uid sets the child process’s user ID. This translates to a setuid call in the child process. Failure in the setuid call will cause the spawn to fail.

opt.gid is similar to opt.uid, but sets the group ID of the child process. This has the same semantics as the uid field.

By default subprocess inherits stdio of parent process. To change this this, opt.stdin, opt.stdout, and opt.stderr can be set independently to a resource ID (rid) of an open file, "inherit", "piped", or "null":

  • number: the resource ID of an open file/resource. This allows you to read or write to a file.
  • "inherit": The default if unspecified. The subprocess inherits from the parent.
  • "piped": A new pipe should be arranged to connect the parent and child sub-process.
  • "null": This stream will be ignored. This is the equivalent of attaching the stream to /dev/null.

Details of the spawned process are returned as an instance of Deno.Process.

Requires allow-run permission.

Spawns new subprocess. RunOptions must contain at a minimum the opt.cmd, an array of program arguments, the first of which is the binary.

const p = Deno.run({
  cmd: ["curl", "https://example.com"],
});
const status = await p.status();

Subprocess uses same working directory as parent process unless opt.cwd is specified.

Environmental variables from parent process can be cleared using opt.clearEnv. Doesn't guarantee that only opt.env variables are present, as the OS may set environmental variables for processes.

Environmental variables for subprocess can be specified using opt.env mapping.

opt.uid sets the child process’s user ID. This translates to a setuid call in the child process. Failure in the setuid call will cause the spawn to fail.

opt.gid is similar to opt.uid, but sets the group ID of the child process. This has the same semantics as the uid field.

By default subprocess inherits stdio of parent process. To change this this, opt.stdin, opt.stdout, and opt.stderr can be set independently to a resource ID (rid) of an open file, "inherit", "piped", or "null":

  • number: the resource ID of an open file/resource. This allows you to read or write to a file.
  • "inherit": The default if unspecified. The subprocess inherits from the parent.
  • "piped": A new pipe should be arranged to connect the parent and child sub-process.
  • "null": This stream will be ignored. This is the equivalent of attaching the stream to /dev/null.

Details of the spawned process are returned as an instance of Deno.Process.

Requires allow-run permission.