From 47e2a0f4b33e39a5ab53d0119538c94c31f44bec Mon Sep 17 00:00:00 2001 From: yannrichet Date: Thu, 28 Dec 2023 19:00:46 +0100 Subject: [PATCH] redirect POST.* output to out.txt --- .../plugin/DefaultCodeLauncher.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/funz/calculator/plugin/DefaultCodeLauncher.java b/src/main/java/org/funz/calculator/plugin/DefaultCodeLauncher.java index d68f0d4..d318d49 100644 --- a/src/main/java/org/funz/calculator/plugin/DefaultCodeLauncher.java +++ b/src/main/java/org/funz/calculator/plugin/DefaultCodeLauncher.java @@ -88,7 +88,7 @@ protected int runCommand() throws Exception { if (prebat.isFile()) { System.err.println("Launching PRE.bat"); try { - new org.funz.util.Process("cmd.exe " + prebat.getName(), _dir, null).runCommand(); + new org.funz.util.Process("cmd.exe " + prebat.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName)); } catch (Exception e) { System.err.println("could not launch PRE.bat:\n" + e); } @@ -98,7 +98,7 @@ protected int runCommand() throws Exception { if (presh.isFile()) { System.err.println("Launching PRE.sh"); try { - new org.funz.util.Process("/bin/sh " + presh.getName(), _dir, null).runCommand(); + new org.funz.util.Process("/bin/sh " + presh.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName)); } catch (Exception e) { System.err.println("could not launch PRE.sh:\n" + e); } @@ -109,19 +109,19 @@ protected int runCommand() throws Exception { System.err.println("Launching PRE.py"); if (ParserUtils.getASCIIFileContent(prepy).contains("print(")) { try { - new org.funz.util.Process("python3 " + prepy.getName(), _dir, null).runCommand(); + new org.funz.util.Process("python3 " + prepy.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName)); } catch (Exception e) { System.err.println("could not launch PRE.py:\n" + e); } } else if (ParserUtils.getASCIIFileContent(prepy).contains("print ")) { try { - new org.funz.util.Process("python2 " + prepy.getName(), _dir, null).runCommand(); + new org.funz.util.Process("python2 " + prepy.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName)); } catch (Exception e) { System.err.println("could not launch PRE.py:\n" + e); } } else { try { - new org.funz.util.Process("python " + prepy.getName(), _dir, null).runCommand(); + new org.funz.util.Process("python " + prepy.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName)); } catch (Exception e) { System.err.println("could not launch PRE.py:\n" + e); } @@ -147,7 +147,7 @@ public void over(int i) { if (postbat.isFile()) { System.err.println("Launching POST.bat"); try { - new org.funz.util.Process("cmd.exe " + postbat.getName(), _dir, null).runCommand(); + new org.funz.util.Process("cmd.exe " + postbat.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName)); } catch (Exception e) { System.err.println("could not launch POST.bat:\n" + e); } @@ -157,7 +157,7 @@ public void over(int i) { if (postsh.isFile()) { System.err.println("Launching POST.sh"); try { - new org.funz.util.Process("/bin/sh " + postsh.getName(), _dir, null).runCommand(); + new org.funz.util.Process("/bin/sh " + postsh.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName)); } catch (Exception e) { System.err.println("could not launch POST.sh:\n" + e); } @@ -168,20 +168,20 @@ public void over(int i) { System.err.println("Launching POST.py"); if (ParserUtils.getASCIIFileContent(postpy).contains("print(")) { try { - new org.funz.util.Process("python3 " + postpy.getName(), _dir, null).runCommand(); + new org.funz.util.Process("python3 " + postpy.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName)); //new org.funz.util.Process("python3 " + postpy.getName()); } catch (Exception e) { System.err.println("could not launch POST.py:\n" + e); } } else if (ParserUtils.getASCIIFileContent(postpy).contains("print ")) { try { - new org.funz.util.Process("python2 " + postpy.getName(), _dir, null).runCommand(); + new org.funz.util.Process("python2 " + postpy.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName)); } catch (Exception e) { System.err.println("could not launch POST.py:\n" + e); } } else { try { - new org.funz.util.Process("python " + postpy.getName(), _dir, null).runCommand(); + new org.funz.util.Process("python " + postpy.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName)); } catch (Exception e) { System.err.println("could not launch POST.py:\n" + e); } @@ -280,7 +280,7 @@ public void stopRunning() { if (killbat.isFile()) { System.err.println("Launching STOP.bat"); try { - new org.funz.util.Process("cmd.exe " + killbat.getName(), _dir, null).runCommand(); + new org.funz.util.Process("cmd.exe " + killbat.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName)); } catch (Exception e) { System.err.println("could not launch STOP.bat:\n" + e); } @@ -291,7 +291,7 @@ public void stopRunning() { if (killsh.isFile()) { System.err.println("Launching STOP.sh"); try { - new org.funz.util.Process("/bin/sh " + killsh.getName(), _dir, null).runCommand(); + new org.funz.util.Process("/bin/sh " + killsh.getName(), _dir, null).runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName)); } catch (Exception e) { System.err.println("could not launch STOP.sh:\n" + e); }