Created
September 5, 2019 18:03
-
-
Save itsfarseen/dc1089e641ecda015c1963f569a1609b to your computer and use it in GitHub Desktop.
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::io::Read; | |
use std::process; | |
fn main() { | |
let cmdline_args: Vec<String> = std::env::args().collect(); | |
let mut path = std::path::Path::new(&cmdline_args[1]).to_path_buf(); | |
let args = &cmdline_args[2..]; | |
let mut proc = process::Command::new(&path) | |
.args(args) | |
.stdout(process::Stdio::piped()) | |
.spawn() | |
.unwrap(); | |
let mut stdout = proc.stdout.take().expect("Failed to take stdout."); | |
let mut s = [0u8; 5]; | |
loop { | |
dbg!(stdout.read(&mut s)); | |
let vec: Vec<u8> = Vec::from(&s as &[u8]); | |
println!("Got: {}", String::from_utf8(vec).unwrap()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment