1dfd3fd98S裕依2439 use std::{env, fs::File, io::Write}; 2909e4d10SGnoCiYeH 3*2069cc0dSBrahmaMantra //const REACH_PIPE_PATH: &str = "/home/fz/myetc/reach/ipc/ctl"; 4*2069cc0dSBrahmaMantra const REACH_PIPE_PATH: &str = "etc/reach/ipc/ctl"; 5909e4d10SGnoCiYeH main()6909e4d10SGnoCiYeHfn main() { 7909e4d10SGnoCiYeH let mut args: Vec<String> = env::args().collect(); 8909e4d10SGnoCiYeH 9909e4d10SGnoCiYeH if args.len() <= 2 { 10909e4d10SGnoCiYeH args = Vec::new(); 11909e4d10SGnoCiYeH args.push(String::from("list-units")); 12909e4d10SGnoCiYeH } else { 13909e4d10SGnoCiYeH args.remove(0); 14909e4d10SGnoCiYeH args.remove(0); 15909e4d10SGnoCiYeH } 16909e4d10SGnoCiYeH 17909e4d10SGnoCiYeH let mut msg = String::new(); 18909e4d10SGnoCiYeH for arg in args { 19909e4d10SGnoCiYeH msg = format!("{} {}", msg, arg); 20909e4d10SGnoCiYeH } 21909e4d10SGnoCiYeH 22dfd3fd98S裕依2439 let mut file = File::open(REACH_PIPE_PATH).unwrap(); 23dfd3fd98S裕依2439 if let Err(err) = file.write_all(msg.as_bytes()) { 24909e4d10SGnoCiYeH eprintln!("write error {}", err); 25*2069cc0dSBrahmaMantra eprintln!("write error {:?}", err); 26909e4d10SGnoCiYeH } 27909e4d10SGnoCiYeH } 28