/** * executes a shell script at "scriptPath". If runningFilePath is not blank and not null, then * Mesquite will create a file there that will serve as a flag to Mesquite that the script is * running. */ public boolean executeInShell() { proc = null; try { ShellScriptUtil.setScriptFileToBeExecutable(scriptPath); if (!StringUtil.blank(runningFilePath)) { if (StringUtil.blank(runningFileMessage)) MesquiteFile.putFileContents(runningFilePath, "Script running...", true); else MesquiteFile.putFileContents(runningFilePath, runningFileMessage, true); if (appendRemoveCommand && MesquiteFile.fileExists(runningFilePath)) MesquiteFile.appendFileContents( scriptPath, StringUtil.lineEnding() + ShellScriptUtil.getRemoveCommand(runningFilePath), true); // append remove command to guarantee that the runningFile is deleted // +StringUtil.lineEnding()+ShellScriptUtil.getExitCommand() } proc = ShellScriptUtil.executeScript(scriptPath, visibleTerminal); } catch (IOException e) { MesquiteMessage.warnProgrammer("IOException in shell script executed by " + name); return false; } return true; }
public ShellScriptRunner( String scriptPath, String runningFilePath, String runningFileMessage, boolean appendRemoveCommand, String name, String[] outputFilePaths, OutputFileProcessor outputFileProcessor, ShellScriptWatcher watcher, boolean visibleTerminal) { this.scriptPath = scriptPath; this.runningFilePath = runningFilePath; if (runningFilePath == null && !StringUtil.blank(scriptPath)) this.runningFilePath = ShellScriptUtil.getDefaultRunningFilePath(); this.runningFileMessage = runningFileMessage; this.appendRemoveCommand = appendRemoveCommand; this.name = name; this.outputFilePaths = outputFilePaths; this.outputFileProcessor = outputFileProcessor; this.watcher = watcher; this.visibleTerminal = visibleTerminal; }