Last active
June 29, 2022 19:38
-
-
Save mr-pascal/829e8ed0872606f5a4287fb27191489d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::process::Command; | |
fn main() { | |
// spawn() | |
println!("Running via 'spawn()'"); | |
let mut out = Command::new("ls") | |
.arg("-l") | |
.arg("-a") | |
.spawn() | |
.expect("ls command failed to start"); | |
out.wait().expect("Failing while waiting"); | |
println!("{:?}", out); | |
// output() | |
println!(""); | |
println!("Running via 'output()'"); | |
let out2 = Command::new("ls") | |
.arg("-l") | |
.arg("-a") | |
.output() | |
.expect("ls command failed to start"); | |
println!(""); | |
println!("{:?}", out2); | |
// status() | |
println!(""); | |
println!("Running via 'status()'"); | |
let out3 = Command::new("ls") | |
.arg("-l") | |
.arg("-a") | |
.status() | |
.expect("ls command failed to start"); | |
println!(""); | |
println!("{:?}", out3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment