package com.platform.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

public class ProcessMyUtil {
	
	private static Logger logger = Logger.getLogger(ProcessMyUtil.class);

	public static List<String> execCmdWaitAcquiescent(String cmd) {
		return runcmd(cmd);
	}
	
	private static List<String> runcmd(String cmd) {
		List<String> result = new ArrayList<String>();
		InputStream in = null;
		String[] cmds = {"/bin/sh", "-c", cmd};
		try {
			Process pro = Runtime.getRuntime().exec(cmds);
			pro.waitFor();
			in = pro.getInputStream();
			BufferedReader read = new BufferedReader(new InputStreamReader(in));
			String line = null;
			while ((line=read.readLine()) != null) {
				result.add(line);
			}
		} catch (IOException e) {
			logger.error(e.getStackTrace());
		} catch (InterruptedException e) {
			logger.error(e.getStackTrace());
		}
		return result;
	}

}
