Command
struct Command
[src]
pub fn inspect(self): string {
return self.inner.inspect();
}
[src]
pub fn inspect(self): string {
return self.inner.inspect();
}
[src]
pub fn new(program: string): Command {
return Command { inner: _Command.new(program) };
}
Constructs a new Command for launching the program at path program.
[src]
pub fn new(program: string): Command {
return Command { inner: _Command.new(program) };
}
Constructs a new Command for launching the program at path program.
Constructs a new Command for launching the program at path program.
use std.process.Command;
let command = Command.new("ls");
[src]
pub fn arg(self, arg: string): Command {
self.inner.arg(arg);
return self;
}
Adds an argument to pass to the program.
[src]
pub fn arg(self, arg: string): Command {
self.inner.arg(arg);
return self;
}
Adds an argument to pass to the program.
Adds an argument to pass to the program.
Modify the Command and return it self.
Only one argument can be passed per use. So instead of:
.arg("-C /path/to/repo")
usage would be:
.arg("-C")
.arg("/path/to/repo")
[src]
pub fn args(self, args: [string]): Command {
self.inner.args(args);
return self;
}
Adds multiple arguments to pass to the program.
[src]
pub fn args(self, args: [string]): Command {
self.inner.args(args);
return self;
}
Adds multiple arguments to pass to the program.
Adds multiple arguments to pass to the program.
Modify the Command and return it self.
To pass a single argument see arg
method.
Note that the arguments are not passed through a shell, but given literally to the program. This means that shell syntax like quotes, escaped characters, word splitting, glob patterns, variable substitution, etc. have no effect.
See also: https://doc.rust-lang.org/std/process/struct.Command.html#method.args
use std.process.Command;
let command = Command.new("ls")
.args(["-l", "-a"]);
current_dir
pub fn current_dir(self, dir: string): Command
[src]
pub fn current_dir(self, dir: string): Command {
self.inner.current_dir(dir);
return self;
}
Sets the working directory for the child process.
current_dir
pub fn current_dir(self, dir: string): Command
[src]
pub fn current_dir(self, dir: string): Command {
self.inner.current_dir(dir);
return self;
}
Sets the working directory for the child process.
Sets the working directory for the child process.
use std.process.Command;
let command = Command.new("ls").current_dir("/tmp");
[src]
pub fn env(self, key: string, value: string): Command {
self.inner.env(key, value);
return self;
}
Inserts or updates an explicit environment variable mapping.
[src]
pub fn env(self, key: string, value: string): Command {
self.inner.env(key, value);
return self;
}
Inserts or updates an explicit environment variable mapping.
Inserts or updates an explicit environment variable mapping.
This method allows you to add an environment variable mapping to the spawned process or overwrite a previously set value.
You can use envs
to set multiple environment variables simultaneously.
Child processes will inherit environment variables from their parent process by default.
Environment variables explicitly set using env
take precedence over inherited variables.
You can disable environment variable inheritance entirely using env_clear
or for a single key using env_remove
.
Note that environment variable names are case-insensitive (but case-preserving) on Windows and case-sensitive on all other platforms.
use std.process.Command;
let command = Command.new("ls").env("PATH", "/bin");
[src]
pub fn envs(self, envs: <string, string>): Command {
self.inner.envs(envs);
return self;
}
Inserts or updates multiple explicit environment variable mappings.
[src]
pub fn envs(self, envs: <string, string>): Command {
self.inner.envs(envs);
return self;
}
Inserts or updates multiple explicit environment variable mappings.
Inserts or updates multiple explicit environment variable mappings.
This method allows you to add multiple environment variable mappings to the spawned process or overwrite previously set values.
You can use env
to set a single environment variable.
Child processes will inherit environment variables from their parent process by default.
Environment variables explicitly set using env
take precedence over inherited variables.
You can disable environment variable inheritance entirely using env_clear
or for a single key using env_remove
.
Note that environment variable names are case-insensitive (but case-preserving) on Windows and case-sensitive on all other platforms.
use std.process.Command;
let command = Command.new("ls")
.envs({ "PATH": "/bin", "HTTP_PROXY": "http://127.0.0.1:1234" });
[src]
pub fn env_clear(self): Command {
self.inner.env_clear();
return self;
}
Clears all explicitly set environment variables and prevents inheriting any parent process environment variables.
[src]
pub fn env_clear(self): Command {
self.inner.env_clear();
return self;
}
Clears all explicitly set environment variables and prevents inheriting any parent process environment variables.
Clears all explicitly set environment variables and prevents inheriting any parent process environment variables.
SYSTEMROOT
is a critical environment variables for Windows, that will keep.
use std.process.Command;
let command = Command.new("ls").env_clear();
[src]
pub fn stderr(self, stderr: string): Command {
self.inner.stderr(stderr);
return self;
}
Configuration for the child process’s standard error (stderr) handle.
[src]
pub fn stderr(self, stderr: string): Command {
self.inner.stderr(stderr);
return self;
}
Configuration for the child process’s standard error (stderr) handle.
Configuration for the child process’s standard error (stderr) handle.
Default is inherit
, when use run
or status
method,
and defaults to piped
when use exec
.
use std.process.Command;
try! Command.new("ls").stderr("null").run();
[src]
pub fn stdin(self, stdin: string): Command {
self.inner.stdin(stdin);
return self;
}
Configuration for the child process’s standard input (stdin) handle.
[src]
pub fn stdin(self, stdin: string): Command {
self.inner.stdin(stdin);
return self;
}
Configuration for the child process’s standard input (stdin) handle.
Configuration for the child process’s standard input (stdin) handle.
Default is inherit
, when use run
or status
method,
and defaults to piped
when use exec
.
use std.process.Command;
try! Command.new("ls").stdin("null").run();
[src]
pub fn stdout(self, stdout: string): Command {
self.inner.stdout(stdout);
return self;
}
Configuration for the child process’s standard output (stdout) handle.
[src]
pub fn stdout(self, stdout: string): Command {
self.inner.stdout(stdout);
return self;
}
Configuration for the child process’s standard output (stdout) handle.
Configuration for the child process’s standard output (stdout) handle.
Default is inherit
, when use run
or status
method,
and defaults to piped
when use exec
.
use std.process.Command;
try! Command.new("ls").stdout("null").run();
[src]
pub fn uid(self, uid: int): Command {
self.inner.uid(uid);
return self;
}
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. Read more
[src]
pub fn uid(self, uid: int): Command {
self.inner.uid(uid);
return self;
}
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. Read more
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. Read more
Unix only, Windows do nothing.
[src]
pub fn gid(self, gid: int): Command {
self.inner.gid(gid);
return self;
}
Similar to uid
, but sets the group ID of the child process. This has the same semantics as the uid
field.
[src]
pub fn gid(self, gid: int): Command {
self.inner.gid(gid);
return self;
}
Similar to uid
, but sets the group ID of the child process. This has the same semantics as the uid
field.
Similar to uid
, but sets the group ID of the child process. This has the same semantics as the uid
field.
Unix only, Windows do nothing.
[src]
pub fn exec(self): Output throws IoError {
let output = try self.inner.output();
return Output {
stdout: output.stdout,
stderr: output.stderr,
status: output.status,
};
}
Executes the command as a child process, waiting for it to finish and
collecting all of its output.
[src]
pub fn exec(self): Output throws IoError {
let output = try self.inner.output();
return Output {
stdout: output.stdout,
stderr: output.stderr,
status: output.status,
};
}
Executes the command as a child process, waiting for it to finish and collecting all of its output.
Executes the command as a child process, waiting for it to finish and collecting all of its output.
By default, stdout and stderr are captured (and used to provide the resulting output). Stdin is not inherited from the parent and any attempt by the child process to read from the stdin stream will result in the stream immediately closing.
use std.process.Command;
let output = try! Command.new("echo").arg("hello").exec();
assert_eq output.status, 0;
assert_eq output.stdout, b"hello\n";
[src]
pub fn run(self): Child throws IoError {
let child = try self.inner.run();
return child as Child;
}
Executes the command as a child process, return a Child
handle to it.
[src]
pub fn run(self): Child throws IoError {
let child = try self.inner.run();
return child as Child;
}
Executes the command as a child process, return a Child
handle to it.
Executes the command as a child process, return a Child
handle to it.
By default, stdin, stdout and stderr are inherited from the parent.
use std.process.Command;
let child = try! Command.new("ls").run();
println("Child pid: ${child.id():?}");
let status = try! child.wait();
println("Exit status: ${status}");
[src]
pub fn status(self): int? throws IoError {
return try self.inner.status();
}
Executes a command as a child process, waiting for it to finish and collecting its status.
[src]
pub fn status(self): int? throws IoError {
return try self.inner.status();
}
Executes a command as a child process, waiting for it to finish and collecting its status.
Executes a command as a child process, waiting for it to finish and collecting its status.
By default, stdin, stdout and stderr are inherited from the parent.
Returns is exit code of the child process.
On Unix, this will return nil
if the process was terminated by a signal.
use std.process.Command;
let code = try! Command.new("ls").status();
println("exit code: ${code}");