Last active
January 26, 2018 08:19
-
-
Save sunnyone/f4368a9997367cc1bbf0ed17172407c9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
extern crate subprocess; | |
use subprocess::Exec; | |
use std::io::BufReader; | |
use std::io::{BufRead}; | |
use std::error::Error; | |
fn execute() -> std::result::Result<(), Box<Error>> { | |
let exec = Exec::cmd("/tmp/hoge.sh") | |
.stderr(subprocess::Redirection::Merge); | |
let stream = exec.stream_stdout()?; | |
let reader = BufReader::new(stream); | |
for (_, line) in reader.lines().enumerate() { | |
println!("OUTPUT: {}", line?); | |
} | |
Ok(()) | |
} | |
fn main() { | |
execute().unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment