Created
December 22, 2019 00:03
-
-
Save DylanJones/66bc380129eb266811ac2e3e3b36e19b to your computer and use it in GitHub Desktop.
i am bad at rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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