Created
October 24, 2019 20:54
-
-
Save RobertApikyan/f0fafe7e58c03a174774edfc87faae5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
public static void main(String[] args) { | |
BashRunner.run("git help"); | |
} | |
public static class BashRunner { | |
private static final Logger log = Logger.getLogger(BashRunner.class.getName()); | |
public static void run(String comand) { | |
Runtime run = Runtime.getRuntime(); | |
try { | |
Process proc = run.exec(new String[]{"C:/cygwin64/bin/bash.exe", "-c", comand}); | |
proc.waitFor(); | |
BufferedReader br = new BufferedReader(new InputStreamReader( | |
proc.getInputStream())); | |
while (br.ready()) | |
System.out.println(br.readLine()); | |
} catch (Exception e) { | |
log.log(Level.SEVERE, "failed " + comand + " ", e); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment