pub fn exec_cmd(cmd: &str)
Expand description
Executes an external command and waits for it to complete.
The command’s output goes to stdout (i.e., not captured).
Similar to Python’s os.system("something")
.
The command must be a simple command with some optional arguments. Pipes, redirections are not allowed.
§Examples
let cmd = "rustc --version";
jabba_lib::jprocess::exec_cmd(cmd);
§Sample Output
rustc 1.62.1 (e092d0b6b 2022-07-16)
Examples found in repository?
More examples
examples/process.rs (line 21)
3fn main() {
4 let commands = vec![
5 r#"python -c "print('Hello Py3!')""#,
6 "python --version",
7 "date",
8 ];
9
10 for cmd in commands.iter() {
11 let stat = jabba_lib::jprocess::get_exitcode_stdout_stderr(cmd).unwrap();
12 println!("{:?}", stat);
13 }
14
15 let date = jabba_lib::jprocess::get_exitcode_stdout_stderr("date")
16 .unwrap()
17 .trimmed_output();
18 println!("{:?}", date);
19
20 let cmd = "ls -al";
21 jproc::exec_cmd(cmd);
22}