#How do I execute a command that runs in the background and returns real-time output?
5 messages · Page 1 of 1 (latest)
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(())
}`
in what way does it not work? Do you see any errors?
the bat runs and so on, I see the logs in the terminal but the window.emit doesn't happen so the frontend doesn't get anything.
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)
