#How do I execute a command that runs in the background and returns real-time output?

5 messages · Page 1 of 1 (latest)

ember ember
#

I've been trying for months and I can't get it, I think I'll never learn rust RatCar

#

this is my last code, as usual, it doesn't work.

`async fn run_install(window: Window) -> Result<(), String> {
let current_dir = env::current_dir().expect("Failed to get current directory");
let rvc_dir = current_dir
.parent()
.expect("Failed to get RVC directory")
.join("core");

let output = Command::new("cmd")
  .arg("/c")
  .arg("install.bat")
  .current_dir(rvc_dir)
  .stdout(Stdio::piped())
  .spawn()
  .expect("Error running command");

let reader = BufReader::new(output.stdout.expect("Error reading command output"));

for line in reader.lines() {
    let line = line.expect("Error reading line");
    window.emit("command-output", line).unwrap();
}

Ok(())

}`

dense lantern
#

in what way does it not work? Do you see any errors?

ember ember
dense lantern
#

hmm, can you add a println!("command-output {:?}" &line); before window.emit and check if that does something in tauri dev mode (it should print something into the same terminal where tauri dev is running)