public static String runFile(final Project project, String filePath) { String result = ""; try { String path = new File(filePath).getPath().replaceFirst("file:\\\\", ""); if (Utils.debug) { Utils.print("running: perl " + "\"" + path + "\""); } String cmd = ((project == null) ? getPerlPath("") : getPerlPath(project)); ; String[] params = {cmd, ((os.equals(os.Windows)) ? "\"" + path + "\"" : path)}; Process p = Runtime.getRuntime().exec(params); BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream())); result = printStream(input); printStream(err); int resultCode = p.waitFor(); if (resultCode != 0) { throw new Exception("Failed to run perl - Code (" + resultCode + ")"); } } catch (Exception e) { e.printStackTrace(); } return result; }
public static String getVersionString(Project project) { if (os.equals(os.Windows)) { return executeCode(project, "\"use Config;print $Config{version};\""); } return executeCode(project, "use Config;print $Config{version};"); }