static int backtick_exitValue; static boolean backtick_verbose; public static String backtick(String cmd) ctex { File outFile = File.createTempFile("_backtick", ""); backtickToFile(cmd, outFile); S result = loadTextFile(outFile.getPath(), ""); if (backtick_verbose) print("[[\n" + result + "]]"); ret result; } public static void backtickToFile(String cmd, File outFile) ctex { File scriptFile = File.createTempFile("_backtick", isWindows() ? ".bat" : ""); String command = cmd + " >" + bashQuote(outFile.getPath()) + " 2>&1"; //Log.info("[Backtick] " + command); try { if (backtick_verbose) print("backtick: command " + command); saveTextFile(scriptFile.getPath(), command); String[] command2; if (isWindows()) command2 = new String[] { scriptFile.getPath() }; else command2 = new String[] { "/bin/bash", scriptFile.getPath() }; if (backtick_verbose) print("backtick: command2 " + structure(command2)); Process process = Runtime.getRuntime().exec(command2); try { process.waitFor(); } catch (InterruptedException e) { throw new RuntimeException(e); } backtick_exitValue = process.exitValue(); if (backtick_verbose) System.out.println("Process return code: " + backtick_exitValue); } finally { scriptFile.delete(); } }