Ben Chuanlong Du's Blog

It is never too late to learn.

Run Shell Command in Rust

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

In [3]:
:sccache 1
Out[3]:
sccache: true
In [4]:
use std::process::Command;
In [5]:
Command::new("bash")
    .arg("-c")
    .arg("echo hello")
    .output()
    .expect("failed to execute process")
Out[5]:
Output { status: ExitStatus(unix_wait_status(0)), stdout: "hello\n", stderr: "" }
In [7]:
Command::new("bash")
    .arg("-c")
    .arg("echo hello")
    .status()
hello
Out[7]:
Ok(ExitStatus(unix_wait_status(0)))
In [ ]:

In [ ]:

In [ ]:

Comments