code: public ScriptResult runScript(String scriptName, Map<String, Object> parameters) {
      Script script =
          dataService.query(SCRIPT, Script.class).eq(ScriptMetadata.NAME, scriptName).findOne();
      if (script == null) {
        throw new UnknownEntityException(SCRIPT, scriptName);
      }
  
      if (script.getParameters() != null) {
        for (ScriptParameter param : script.getParameters()) {
          if (!parameters.containsKey(param.getName())) {
            throw new GenerateScriptException("Missing parameter [" + param + "]");
          }
        }
      }
  
      Map<String, Object> scriptParameters = new HashMap<>(parameters);
      if (script.isGenerateToken()) {
        String token =
            tokenService.generateAndStoreToken(
                SecurityUtils.getCurrentUsername(), "For script " + script.getName());
        scriptParameters.put("molgenisToken", token);
      }
  
      ScriptRunner scriptRunner =
          scriptRunnerFactory.getScriptRunner(script.getScriptType().getName());
  
      FileMeta fileMeta = null;
      if (scriptRunner.hasFileOutput(script)) {
        String name = generateRandomString();
        String resultFileExtension = script.getResultFileExtension();
        if (resultFileExtension != null) {
          name += "." + script.getResultFileExtension();
        }
        File file = fileStore.getFileUnchecked(name);
        scriptParameters.put("outputFile", file.getAbsolutePath());
        fileMeta = createFileMeta(name, file);
        dataService.add(FILE_META, fileMeta);
      }
      String output = scriptRunner.runScript(script, scriptParameters);
  
      return new ScriptResult(fileMeta, output);
    }
docs: Run a script with parameters.
  
  @param scriptName name of the script to run
  @param parameters parameters for the script
  @return ScriptResult
  @throws UnknownScriptException if scriptName is unknown
  @throws GenerateScriptException , if parameter is missing