SHARE
TWEET

Untitled

a guest Jul 20th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![allow(unused)]
  2.  
  3. use std::process::Command;
  4.  
  5. fn main() {
  6.     let mut sttcmd = Command::new("systemctl");
  7.     let mut sttrpt = Vec::new();
  8.     let mut stterr = Vec::new();
  9.     let mut sttstt: Option<i32> = Some(0);
  10.  
  11.     sttcmd.args(&["status", "some_service", "-l"]);
  12.  
  13.     let mut osttrs = match sttcmd.output() {
  14.         Ok(rs) => Some(rs),
  15.         Err(e) => {
  16.             stterr.push(Vec::from(
  17.                 "cmd 'systemctl status some_service -l': execution failed!",
  18.             ));
  19.             stterr.push(Vec::from(format!("msg: '{:?}'", e)));
  20.            
  21.             sttstt = Some(1);
  22.  
  23.             None
  24.         }
  25.     };
  26.  
  27.     if osttrs.is_some() {
  28.         sttrpt.push(osttrs.as_ref().unwrap().stdout);
  29.         stterr.push(osttrs.as_ref().unwrap().stderr);
  30.         sttstt = osttrs.as_ref().unwrap().status.code();
  31.     }
  32.  
  33.     println!("stt stt (code: '{}'):\n", sttstt.unwrap());
  34.     println!("stt rpt vec u8 (count: '{}'):\n{:?}", sttrpt.len(), sttrpt);
  35.     println!("stt err vec u8 (count: '{}'):\n{:?}", stterr.len(), stterr);
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top