Java Shell Command runShell(String shStr)

Here you can find the source of runShell(String shStr)

Description

run Shell

License

Open Source License

Declaration

public static List runShell(String shStr) throws Exception 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static List runShell(String shStr) throws Exception {
        List<String> strList = new ArrayList();

        Process process;//from   w  w  w.j a  v  a2s.c  o m
        process = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", shStr }, null, null);
        InputStreamReader ir = new InputStreamReader(process.getInputStream());
        LineNumberReader input = new LineNumberReader(ir);
        String line;
        process.waitFor();
        while ((line = input.readLine()) != null) {
            strList.add(line);
        }

        return strList;
    }
}

Related

  1. runCommandGetOutput(String startFolder, String[] args, int[] cmdReturnValue)
  2. runCommandPrompt(final String commandLine, final IPath path)
  3. runCommandWithOutput(String cmd)
  4. runShell(File workspace, String... shellElements)
  5. runShell(String cmd)
  6. runShellCommand(String command)
  7. runShellCommand(String command)
  8. runShellCommand(String command)
  9. runShellCommand(String[] cmd, StringBuilder outputLines, StringBuilder errorLines)