Struct inapi::Command [] [src]

pub struct Command { /* fields omitted */ }

Primitive for running shell commands.

On your host, commands are passed to /bin/sh -c to be executed.

Examples

Initialise a new Host:

let mut host = Host::connect("hosts/myhost.json").unwrap();

Now run your command and get the result:

let cmd = Command::new("whoami");
let result = cmd.exec(&mut host).unwrap();
println!("I am running as {}", result.stdout);

If all goes well, this will output something like:

I am running as root

Methods

impl Command
[src]

[src]

Create a new Command to represent your shell command.

[src]

Execute command on shell.

Command structs are reusable accross multiple hosts, which is helpful if you are configuring a group of servers simultaneously.

Examples

let cmd = Command::new("whoami");

let mut web1 = Host::connect("data/hosts/web1.json").unwrap();
let w1_result = cmd.exec(&mut web1).unwrap();

let mut web2 = Host::connect("data/hosts/web2.json").unwrap();
let w2_result = cmd.exec(&mut web2).unwrap();