package net.northking.cctp.element.mobile.utils;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;


public class RuntimeUtils {
	private static final Logger log = LoggerFactory.getLogger(RuntimeUtils.class);

	public static String execComand(String cmd,String... args) throws Exception {
		log.info("Execute command:{},args:{}",cmd, Arrays.toString(args));
		Process p = Runtime.getRuntime().exec(cmd,args);
		p.waitFor();
		BufferedReader  b = new BufferedReader(new InputStreamReader(p.getInputStream()));
		String line = null;
		while ((line=b.readLine())!=null) {
			log.debug("cmdline ===> {}",line);
		}
		return line;
	}

}
