Is there a way to invoke a system command, like ls or fuser in Rust? How about capturing its output?
ls
fuser
std::process::Command allows for that.
std::process::Command
There are multiple ways to spawn a child process and execute an arbitrary command on the machine:
spawn
output
status
One simple example from the docs:
use std::process::Command; Command::new("ls") .arg("-l") .arg("-a") .spawn() .expect("ls command failed to start");
1.4m articles
1.4m replys
5 comments
57.0k users