Execute groovy script engine t.

@param <T>        the type parameter
@param scriptFile the script file
@param args       the args
@param clazz      the clazz
@return the t
423632
public static <T> T executeScriptEngine(final String scriptFile, final Object[] args, final Class<T> clazz) {
        try {
            val engineName = getScriptEngineName(scriptFile);
            val engine = new ScriptEngineManager().getEngineByName(engineName);
            if (engine == null || StringUtils.isBlank(engineName)) {
                LOGGER.warn("Script engine is not available for [{}]", engineName);
                return null;
            }

            val resourceFrom = ResourceUtils.getResourceFrom(scriptFile);
            val theScriptFile = resourceFrom.getFile();
            if (theScriptFile.exists()) {
                LOGGER.debug("Created object instance from class [{}]", theScriptFile.getCanonicalPath());

                try (val reader = Files.newBufferedReader(theScriptFile.toPath(), StandardCharsets.UTF_8)) {
                    engine.eval(reader);
                }
                val invocable = (Invocable) engine;
                LOGGER.debug("Executing script's run method, with parameters [{}]", args);
                val result = invocable.invokeFunction("run", args);
                LOGGER.debug("Groovy script result is [{}]", result);
                return getGroovyScriptExecutionResultOrThrow(clazz, result);
            }
            LOGGER.warn("[{}] script [{}] does not exist, or cannot be loaded", StringUtils.capitalize(engineName), scriptFile);
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
        return null;
    }
435337
public static <T> T executeGroovyScript(final GroovyObject groovyObject,
                                            final Object[] args, final Class<T> clazz,
                                            final boolean failOnError) {
        return executeGroovyScript(groovyObject, "run", args, clazz, failOnError);
    }
1177572
protected PreparedStatement executeSqlFromScript(String script,
    MapSqlParameterSource args)
  {
    File fScript = new File(scriptPath, script);
    if (fScript.canRead() && fScript.isFile())
    {
      Resource resource = new FileSystemResource(fScript);
      log.debug("executing SQL script: " + resource.getFilename());
      String sql = readSqlFromResource(resource);
      return executeSql(sql, args);
    }
    else
    {
      log.debug("SQL script " + fScript.getName() + " does not exist");
      return null;
    }
  }
721535
protected void runScript(File script) {
        if (!script.exists()) {
            JOptionPane.showMessageDialog(cliGuiCtx.getMainPanel(), script.getAbsolutePath() + " does not exist.",
                                          "Unable to run script.", JOptionPane.ERROR_MESSAGE);
            return;
        }

        int choice = JOptionPane.showConfirmDialog(cliGuiCtx.getMainPanel(), "Run CLI script " + script.getName() + "?",
                                                   "Confirm run script", JOptionPane.YES_NO_OPTION);
        if (choice != JOptionPane.YES_OPTION) return;

        menu.addScript(script);

        cliGuiCtx.getTabs().setSelectedIndex(1); // set to Output tab to view the output
        output.post("\n");

        SwingWorker scriptRunner = new ScriptRunner(script);
        scriptRunner.execute();
    }
364799
public Object evaluate(final String scriptText, final String fileName, final String codeBase) throws CompilationFailedException {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkPermission(new GroovyCodeSourcePermission(codeBase));
        }

        GroovyCodeSource gcs = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
            public GroovyCodeSource run() {
                return new GroovyCodeSource(scriptText, fileName, codeBase);
            }
        });

        return evaluate(gcs);
    }
395184
public <T> T execute(final String methodName, final Class<T> clazz, final Object... args) {
        return execute(methodName, clazz, true, args);
    }
317720
private void processFiles() throws CompilationFailedException, IOException, URISyntaxException {
        GroovyShell groovy = new GroovyShell(conf);
        setupContextClassLoader(groovy);

        Script s = groovy.parse(getScriptSource(isScriptFile, script));

        if (args.isEmpty()) {
            try(BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
                PrintWriter writer = new PrintWriter(System.out);
                processReader(s, reader, writer);
                writer.flush();
            }
        } else {
            Iterator i = args.iterator();
            while (i.hasNext()) {
                String filename = (String) i.next();
                //TODO: These are the arguments for -p and -i.  Why are we searching using Groovy script extensions?
                // Where is this documented?
                File file = huntForTheScriptFile(filename);
                processFile(s, file);
            }
        }
    }
1168620
@Override
    public Object executeScript(String script)
    {
        Object result = mongoDb.eval(script);
        KunderaCoreUtils.printQuery("Execute mongo jscripts:" + script, showQuery);
        return result;
    }
467211
public Object run(GroovyCodeSource source, String[] args) throws CompilationFailedException {
        Class scriptClass = parseClass(source);
        return runScriptOrMainOrTestOrRunnable(scriptClass, args);
    }
198553
public void exec(final MainRemote.Script script) throws Exception {
        final File file = File.createTempFile("takes-", ".txt");
        if (!file.delete()) {
            throw new IOException(
                String.format(
                    // @checkstyle LineLength (1 line)
                    "The temporary file '%s' could not be deleted before calling the exec method",
                    file.getAbsolutePath()
                )
            );
        }
        final Method method = this.app.getDeclaredMethod(
            "main", String[].class
        );
        final String[] passed = new String[1 + this.args.length];
        passed[0] = String.format("--port=%s", file.getAbsoluteFile());
        for (int idx = 0; idx < this.args.length; ++idx) {
            passed[idx + 1] = this.args[idx];
        }
        final Thread thread = new Thread(new MainMethod(method, passed));
        thread.start();
        try {
            script.exec(
                URI.create(
                    String.format(
                        "http://localhost:%d",
                        MainRemote.port(file)
                    )
                )
            );
        } catch (final IOException ex) {
            if (!file.delete()) {
                ex.addSuppressed(
                    new IOException(
                        String.format(
                            // @checkstyle LineLength (1 line)
                            "The temporary file '%s' could not be deleted while catching the error",
                            file.getAbsolutePath()
                        )
                    )
                );
            }
            throw ex;
        } finally {
            thread.interrupt();
        }
        if (!file.delete()) {
            throw new IOException(
                String.format(
                    // @checkstyle LineLength (1 line)
                    "The temporary file '%s' could not be deleted after calling the exec method",
                    file.getAbsolutePath()
                )
            );
        }
    }
511681
public Object run(File scriptFile, List list) throws CompilationFailedException, IOException {
        String[] args = new String[list.size()];
        return run(scriptFile, (String[]) list.toArray(args));
    }
149097
public static void groovy( String file, String ll, String cmd ) throws Exception {
        String f = CLI.readFile(file);
        Object o = CLI.createSim(f, true, ll);
    }
30996
public PythonExecutionResult exec(String script, Map<String, Serializable> callArguments) {
        checkValidInterpreter();
        initInterpreter();
        prepareInterpreterContext(callArguments);

        Exception originException = null;
        for(int i = 0; i < RETRIES_NUMBER_ON_THREADED_ISSUE; i++) {
            try {
                return exec(script);
            } catch (Exception e) {
                if(!isThreadsRelatedModuleIssue(e)) {
                    throw new RuntimeException("Error executing python script: " + e, e);
                }
                if(originException == null) {
                    originException = e;
                }
            }
        }
        throw new RuntimeException("Error executing python script: " + originException, originException);
    }
1121719
public void script(String line, DispatchCallback callback) {
    if (sqlLine.getScriptOutputFile() == null) {
      startScript(line, callback);
    } else {
      stopScript(line, callback);
    }
  }
593847
def run_script_from_macro(self, args):
        
        self.__macroArgs = args["args"].split(',')
        
        try:
            self.run_script(args["name"])
        except Exception as e:
            self.set_return_value("{ERROR: %s}" % str(e))
887503
public static String generateScript(Script script, Map<String, Object> parameterValues) {
    StringWriter stringWriter = new StringWriter();
    try {
      Template template =
          new Template(null, new StringReader(script.getContent()), new Configuration(VERSION));
      template.process(parameterValues, stringWriter);
    } catch (TemplateException | IOException e) {
      throw new GenerateScriptException(
          "Error processing parameters for script [" + script.getName() + "]. " + e.getMessage());
    }
    return stringWriter.toString();
  }
76547
@Override
  public Object eval(final byte[] script, final List<byte[]> keys, final List<byte[]> args) {
    return eval(script, toByteArray(keys.size()), getParamsWithBinary(keys, args));
  }