Skip to content

Instantly share code, notes, and snippets.

@sunnyone
Last active January 26, 2018 08:19
Show Gist options
  • Save sunnyone/f4368a9997367cc1bbf0ed17172407c9 to your computer and use it in GitHub Desktop.
Save sunnyone/f4368a9997367cc1bbf0ed17172407c9 to your computer and use it in GitHub Desktop.
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