package com.platform.utils;

/**
 * Created by Hb_zzZ on 2020/3/24.
 */
public class SheelUtil {

    public static void callshell(String command)
    {
        try {
            Process process = Runtime.getRuntime().exec(command);
            //process.waitFor();
        	/*
        	 // 注意下面的操作
        	 String ls_1;
        	 BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(process.getInputStream()));
        	 while ( (ls_1=bufferedReader.readLine()) != null);
        	 bufferedReader.close();
        	 process.waitFor();
        	 */
            //doWaitFor(process) ;

            StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
            errorGobbler.start();
            StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
            outGobbler.start();
            process.waitFor();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
