Java slf4j Logger callShell(final String shellString, final Logger log)

Here you can find the source of callShell(final String shellString, final Logger log)

Description

call Shell

License

Apache License

Declaration

public static void callShell(final String shellString, final Logger log) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import org.slf4j.Logger;

public class Main {
    public static void callShell(final String shellString, final Logger log) {
        Process process = null;//from  w w w . j  a  va 2 s.  co m
        try {
            String[] cmdArray = splitShellString(shellString);
            process = Runtime.getRuntime().exec(cmdArray);
            process.waitFor();
            log.info("callShell: <{}> OK", shellString);
        } catch (Throwable e) {
            log.error("callShell: readLine IOException, " + shellString, e);
        } finally {
            if (null != process)
                process.destroy();
        }
    }

    private static String[] splitShellString(final String shellString) {
        String[] split = shellString.split(" ");
        return split;
    }
}

Related

  1. alarm(String string)
  2. caught(Exception e, String... bizDesc)
  3. checkInterrupted(String type, String name, Logger logger)
  4. cleanLoggingMdc()
  5. clearRequestId()