1 use std::{env, fs::File, io::Write}; 2 3 //const REACH_PIPE_PATH: &str = "/home/fz/myetc/reach/ipc/ctl"; 4 const REACH_PIPE_PATH: &str = "etc/reach/ipc/ctl"; 5 6 fn main() { 7 let mut args: Vec<String> = env::args().collect(); 8 9 if args.len() <= 2 { 10 args = Vec::new(); 11 args.push(String::from("list-units")); 12 } else { 13 args.remove(0); 14 args.remove(0); 15 } 16 17 let mut msg = String::new(); 18 for arg in args { 19 msg = format!("{} {}", msg, arg); 20 } 21 22 let mut file = File::open(REACH_PIPE_PATH).unwrap(); 23 if let Err(err) = file.write_all(msg.as_bytes()) { 24 eprintln!("write error {}", err); 25 eprintln!("write error {:?}", err); 26 } 27 } 28