From 9020370f748670a57a51b6e08c226f6cd741ea34 Mon Sep 17 00:00:00 2001 From: strNophix Date: Tue, 21 Jun 2022 18:35:53 +0200 Subject: [PATCH] Execute a program --- src/main.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2f1aee1..fad77a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,21 +1,21 @@ // Usage: your_docker.sh run ... fn main() { // You can use print statements as follows for debugging, they'll be visible when running tests. - println!("Logs from your program will appear here!"); + // println!("Logs from your program will appear here!"); // Uncomment this block to pass the first stage! - // let args: Vec<_> = std::env::args().collect(); - // let command = &args[3]; - // let command_args = &args[4..]; - // let output = std::process::Command::new(command) - // .args(command_args) - // .output() - // .unwrap(); - // - // if output.status.success() { - // let std_out = std::str::from_utf8(&output.stdout).unwrap(); - // println!("{}", std_out) - // } else { - // std::process::exit(1); - // } + let args: Vec<_> = std::env::args().collect(); + let command = &args[3]; + let command_args = &args[4..]; + let output = std::process::Command::new(command) + .args(command_args) + .output() + .unwrap(); + + if output.status.success() { + let std_out = std::str::from_utf8(&output.stdout).unwrap(); + println!("{}", std_out) + } else { + std::process::exit(1); + } }