Skip to content

Instantly share code, notes, and snippets.

@DylanJones
Created December 22, 2019 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DylanJones/66bc380129eb266811ac2e3e3b36e19b to your computer and use it in GitHub Desktop.
Save DylanJones/66bc380129eb266811ac2e3e3b36e19b to your computer and use it in GitHub Desktop.
i am bad at rust
use std::process;
use std::io;
fn main() {
let server_process = match process::Command::new("bash")
.arg("-c")
.arg("for i in 1 2 3 4 5 6 7 8 9; do echo hello; sleep 1; done")
.stdout(process::Stdio::piped())
.stdin(process::Stdio::piped())
.spawn() {
Err(why) => panic!("Failed to start server: {}", why),
Ok(proc) => proc,
};
// let output = server_process.wait_with_output();
let reader = io::BufReader::new(server_process.stdout.as_mut().unwrap());
loop {
let mut line = String::new();
reader.read_line(&mut line).unwrap();
println!("{}", line);
// reader.lines().for_each(|line| println!("{}", line));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment