Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Get The Text Output From An External Command In Rust

use std::process::Command;

fn main() {
    let args = vec!["-l"];
    let response = Command::new("ls")
        .args(args)
        .output()
        .expect("did not work");
    let text = String::from_utf8_lossy(&response.stdout);
    dbg!(text);
}

- The default that comes back from output is a [TODO: Code shorthand span ] that has to be turned into a string to output it if you want to see it as letters.

- I wouldn't be surprised to find other ways to do this.