Command.output() captures the process output and returns it as a Vec<u8> that you can use inside your program. If you don’t need the output and want to let the program access the console, use Command.status instead:
use std::process::Command;
fn main()
{
let mut output = Command::new("sh");
output.arg("-c").arg("echo hello");
output.status().expect("Error!");
}
sh is the POSIX-standard command interpreter; it’s usually the program that runs automatically when you open a new terminal. -c tells it to interpret the next argument as an explicit command instead of the filename of a script that it should run.