одну строчку вывода либо ничего. Что я делаю не так? Может нужно использовать какой-то итератор? 
                  
                  
                  use std::process::Command;
                  
                  
                  fn print_command_stdout(cmd: &str) {
                  
                  
                      let output = Command::new(cmd)
                  
                  
                          .arg("")
                  
                  
                          .arg("")
                  
                  
                          .output()
                  
                  
                          .expect("failed");
                  
                  
                      let s = std::str::from_utf8(&output.stdout).expect("конвертация в строку сломалась");
                  
                  
                      print!("{:?}", s);
                  
                  
                  }
                  
                  
                  
                  
                  
                  fn main() {
                  
                  
                      print_command_stdout("fasm");
                  
                  
                      print_command_stdout("lsblk");
                  
                  
                      print_command_stdout("ls");
                  
                  
                  }
                  
                  
                
https://doc.rust-lang.org/stable/std/process/struct.Command.html#method.stderr либо выводи output.stderr
Спасибо. До конца не разобрался с причинами поведения, сделал так, работает как часы. На будущее учту проверку stderr: fn test_external_command(cmd: &str) { use std::process::{Command, Stdio}; let child = Command::new(cmd) .spawn() .expect("failed to execute child"); let output = child .wait_with_output() .expect("failed to wait on child"); let s = std::str::from_utf8(&output.stdout).expect("конвертация в строку сломалась"); println!("{}", s); }
Обсуждают сегодня