【发布时间】:2018-05-23 19:28:33
【问题描述】:
如何在 Windows 10 环境中从 Java 运行在 Ubuntu 上用 Bash 编写的 shell 脚本?
我正在尝试使用此代码,但它没有运行也没有执行脚本。
public static void main(String[] args) throws IOException {
Runtime rt = Runtime.getRuntime();
ProcessBuilder builder = new ProcessBuilder(
"bash.exe", "/mnt/d/Kaldi-Java/kaldi-trunk/tester.sh");
Process p = builder.start();
BufferedReader r = new BufferedReader(new
InputStreamReader(p.getInputStream()));
String line;
while (true) {
line = r.readLine();
if (line != null) { System.out.print(line);}
else{break;}
}
}
【问题讨论】:
-
bash.exe 可能必须是完全限定的并且您已经定义了一个冗余的运行时...