<pre>
Executes a script to handle the request that matches this URL
pattern.
</pre>

<code>.google.appengine.v1.ScriptHandler script = 3;</code>
547959
public com.google.appengine.v1.ScriptHandlerOrBuilder getScriptOrBuilder() {
    if (handlerTypeCase_ == 3) {
       return (com.google.appengine.v1.ScriptHandler) handlerType_;
    }
    return com.google.appengine.v1.ScriptHandler.getDefaultInstance();
  }
314981
private static void executeSqlScript(Connection connection, URL scriptUrl) throws SQLException {
        for (String sqlStatement : readSqlStatements(scriptUrl)) {
            if (!sqlStatement.trim().isEmpty()) {
                connection.prepareStatement(sqlStatement).executeUpdate();
            }
        }
    }
313922
@Override
    public Script resolveScript(String name) throws JellyException {
        // cut off the extension so that we can search all the extensions
        String shortName;
        int dot = name.lastIndexOf('.');
        if (dot>name.lastIndexOf('/'))      shortName = name.substring(0, dot);
        else                                shortName = name;

        for (Facet f : owner.webApp.facets) {
            if (f instanceof JellyCompatibleFacet && !(f instanceof JellyFacet)) {
                JellyCompatibleFacet jcf = (JellyCompatibleFacet) f;
                for (Class<? extends AbstractTearOff<?,? extends Script,?>> ct : jcf.getClassTearOffTypes()) {
                    try {
                        Script s = owner.loadTearOff(ct).resolveScript(shortName);
                        if (s!=null)    return s;
                    } catch (Exception e) {
                        throw new JellyException("Failed to load "+shortName+" from "+jcf,e);
                    }
                }
            }
        }

        return super.resolveScript(name);
    }
1193175
function executeOnready( script, fn, Class, data ) {

			// for instance of: check if given class is a interface implemeted by
			// host class.
			var self = this;
			this.getClass = function( ) {
				return self;
			};

			this.new = function () {
				return new self(arguments, '___argslist___');
			};

			this.toString = function( ) {
				return script.Class;
			};
			if(script.baseClass){
				this.base = fm.stringToObject(script.baseClass);
				this.prototype.getSub = function( ) {
					return self;
				};
			}

			this.serialize = Serialize;
			this.clone = function(){
				var data = this.serialize(null, true);
				var instance = new (this.getClass())(data);
				for(var k in data) {
					instance[k] = data[k];
				}
				return instance;
			};

			creareSetGet(this);
			script.ics = getAllImportClass(script.imports);
			script.args = getAllArgsSequence(Class);
			getReleventClassInfo.call(script, Class, fn, this);
	        this.package = script.Package;
			typeof script.shortHand == 'string' && addShortHand(script.shortHand, this);
			this.isAbstract = script.isAbstract;
			//
			// Do not add script info in proto fror interface
			// script.isInterface && addFieldsInStorage.call(pofn, script, pofn,
			// true);
			this.prototype.$get = function( key ) {
				return script[key];
			};

			createSetterGetter.call(this);

			function isInterface( cls ) {
				var interfs = script.interfaces || [];
				for ( var k = 0, len = interfs.length; k < len; k++) {
					if (createObj(interfs[k]).instanceOf(cls)) {
						return true;
					}
				}
				return false;
			}
			this.equals = function( ) {
				return this === arguments[0];
			};
			this.instanceOf = function( cls ) {
	            if (!cls) return false;
				return cls.getClass() == this.getClass() || this.base && this.base.instanceOf(cls) || isInterface(cls);
			};

			var obj ={};
			for (var i in this) {
				if(typeof this[i] === 'function'){
					obj[i] = this[i];
					continue;
				}
				(function(i){
					function getter(){
						return self[i];
					};
					function setter(v){
						self[i] = v;
					}
					 if (Object.defineProperty) {
						Object.defineProperty(obj, i, {
							get : getter,
							set : setter
						});
					}
					else if (obj.__defineGetter__) {
						obj.__defineGetter__(i, getter);
						obj.__defineSetter__(i, setter);
					}else{
						obj[i] = self[i];
					}
				})(i);
			};
			obj.prototype = this.prototype;
			Class.prototype = obj;
			fileLoadeManager.iamready(this.getClass().toString(), this);
			if(data && typeof data[data.length -1] == 'function'){
				(function(fun){
					setTimeout(function(){
						fun(self);
					});
				})(data.pop())
			}
			if (typeof this.main == 'function') {
				var s= this;
				setTimeout(function(){
					s.main(data);
					delete s.main;
				});
			}


			data = undefined;
			if( typeof this.__iamready == "function") {
				this.__iamready(this);
			}
		}
477597
public static Object eval(String script, ScriptContext context) throws ScriptRuntimeException {
		try {
			return compile(script).eval(context);
		} catch (ScriptException e) {
			throw new ScriptRuntimeException(e);
		}
	}
890050
public <T> T eval(String name, final String script, Map<String,Object> data) throws ScriptException,ScriptLimitException,SyntaxException {
        long t = System.currentTimeMillis();
        if(data==null)
            data = Objects.newHashMap();
        if(script.length()>sizeLimit)
            throw new ScriptLimitException(ScriptLimitException.Limits.SIZE,getSizeLimit());
        if(LOG.isDebugEnabled()){
            LOG.debug("Evaluating S1 script:\n"+script+"\nWith data:"+data);
        }

        AstRoot _root = null;
        if(Objects.isNullOrEmpty(name)){
            _root = parseScript(script);
        }else{
            _root = astCache.get(name,new Closure<String, AstRoot>() {
                @Override
                public AstRoot call(String input) {
                    return parseScript(script);
                }
            });
        }
        final AstRoot root = _root;

        final Context ctx=new Context(getMemoryLimit());
        ctx.getVariables().putAll(data);

        //functions from options
        for(final Map<String,Object> f:functions){
            String clName = Objects.get(f,"class");
            String ns = Objects.get(f,"namespace","");
            Map<String,Object> set_cfg = Objects.get(f,"config",Objects.newSOHashMap());
            Class<? extends ScriptFunctionSet> cls = null;
            try {
                cls = (Class<? extends ScriptFunctionSet>)Class.forName(clName);
                ScriptFunctionSet set = cls.newInstance();
                set.setConfig(set_cfg);
                set.setContext(new Context(getMemoryLimit()));
                Objects.set(ctx.getVariables(),ns,set);
            } catch (Throwable e) {
                LOG.warn("Class "+cls+" cannot be initialized as ScriptFunctions: "+e.getMessage(),e);
            }
        }

        //system functions
        ScriptFunctionSet set = new SystemFunctionSet();
        //set.setConfig(set_cfg);
        set.setContext(new Context(getMemoryLimit()));
        Objects.set(ctx.getVariables(),SYSTEM_FUNCTION_NS,set);

        final Session.SessionBean sb = Session.getSessionBean();

        Future<Object> f = null;
        if(isInside.get() == null || !isInside.get()) {
            if (sb != null) {
                //run script
                f = getService().submit(new Callable<Object>() {
                    @Override
                    public Object call() throws Exception {
                        String id = null;
                        try {
                            isInside.set(true);
                            id = Session.start(sb.getId());
                            ASTEvaluator ast = new ASTEvaluator();
                            Object o = ast.eval(root, ctx);
                            return o;
                        } finally {
                            Session.end(id);
                            isInside.set(false);
                        }
                    }
                });
            } else {
                //run script
                f = getService().submit(new Callable<Object>() {
                    @Override
                    public Object call() throws Exception {
                        try {
                            isInside.set(true);
                            ASTEvaluator ast = new ASTEvaluator();
                            Object o = ast.eval(root, ctx);
                            return o;
                        }finally {
                            isInside.set(false);
                        }
                    }
                });
            }
        }

        try {
            long l = System.currentTimeMillis();
            T result = null;
            /*try {
                // Try to get answer in short timeout, should be available
                result = (T)f.get(getTimeLimit(), TimeUnit.MILLISECONDS);
            } catch (TimeoutException te) {
                f.cancel(true);
                throw new ScriptLimitException(ScriptLimitException.Limits.TIME,getTimeLimit());
            }*/
            if(f==null || getTimeLimit()<=0){
                ASTEvaluator ast = new ASTEvaluator();
                result = (T)ast.eval(root, ctx);
            }else {
                while (true) {
                    if (System.currentTimeMillis() - l > getTimeLimit()) {
                        f.cancel(true);
                        throw new ScriptLimitException(ScriptLimitException.Limits.TIME, getTimeLimit());
                    }

                    if (f.isDone()) {
                        break;
                    }
                    Thread.sleep(1);
                }
                result = (T) f.get();
            }
            if(LOG.isDebugEnabled()){
                LOG.debug("Script result ("+(System.currentTimeMillis()-t)+"ms.): "+result);
            }
            return result;
        } catch (InterruptedException e){
            throw S1SystemError.wrap(e);
        } catch (ExecutionException e){
            if(e.getCause()!=null){
                if(e.getCause() instanceof ScriptLimitException)
                    throw (ScriptLimitException)e.getCause();
                if(e.getCause() instanceof ScriptException) {
                    ScriptException se = (ScriptException) e.getCause();
                    int line = se.getLine();
                    if(line>=0){
                        String arr [] = script.split("\n",-1);
                        String m = (arr.length>line?(arr[line]):"");
                        se.setCode(m);
                        throw se;
                    }
                    throw se;
                }
            }
            throw S1SystemError.wrap(e);
        } catch (ScriptException se){
            int line = se.getLine();
            if(line>=0){
                String arr [] = script.split("\n",-1);
                String m = (arr.length>line?(arr[line]):"");
                se.setCode(m);
                throw se;
            }
            throw se;
        }
    }
335997
public Object run(final File scriptFile, String[] args) throws CompilationFailedException, IOException {
        String scriptName = scriptFile.getName();
        int p = scriptName.lastIndexOf(".");
        if (p++ >= 0) {
            if (scriptName.substring(p).equals("java")) {
                throw new CompilationFailedException(0, null);
            }
        }

        // Get the current context classloader and save it on the stack
        final Thread thread = Thread.currentThread();
        //ClassLoader currentClassLoader = thread.getContextClassLoader();

        class DoSetContext implements PrivilegedAction {
            ClassLoader classLoader;

            public DoSetContext(ClassLoader loader) {
                classLoader = loader;
            }

            public Object run() {
                thread.setContextClassLoader(classLoader);
                return null;
            }
        }

        AccessController.doPrivileged(new DoSetContext(loader));

        // Parse the script, generate the class, and invoke the main method.  This is a little looser than
        // if you are compiling the script because the JVM isn't executing the main method.
        Class scriptClass;
        try {
            scriptClass = AccessController.doPrivileged(new PrivilegedExceptionAction<Class>() {
                public Class run() throws CompilationFailedException, IOException {
                    return loader.parseClass(scriptFile);
                }
            });
        } catch (PrivilegedActionException pae) {
            Exception e = pae.getException();
            if (e instanceof CompilationFailedException) {
                throw (CompilationFailedException) e;
            } else if (e instanceof IOException) {
                throw (IOException) e;
            } else {
                throw (RuntimeException) pae.getException();
            }
        }

        return runScriptOrMainOrTestOrRunnable(scriptClass, args);

        // Set the context classloader back to what it was.
        //AccessController.doPrivileged(new DoSetContext(currentClassLoader));
    }
616835
@Override
	public StringBuffer getClientSideHandlerScript(HttpServletRequest request) {

		StringBuffer sb = getHeaderSection(request);

		boolean useGzip = RendererRequestUtils.isRequestGzippable(request, this.config);

		Map<String, String> variants = this.config.getGeneratorRegistry().resolveVariants(request);
		sb.append("JAWR.loader.mapping='").append(getPathPrefix(request, this.config)).append("';\n");

		// Start an self executing function
		sb.append("(function(){\n");

		// shorthand for creating ResourceBundles. makes the script shorter.
		sb.append("function r(n, p, i,ie,aU){return new JAWR.ResourceBundle(n, p, i,ie,aU);}\n");

		sb.append("JAWR.loader.jsbundles = [");
		sb.append(getClientSideBundles(variants, useGzip));
		sb.append("]\n");

		// Retrieve the resourcehandler for CSS if there is one.
		ResourceBundlesHandler rsHandler = (ResourceBundlesHandler) request.getSession().getServletContext()
				.getAttribute(JawrConstant.CSS_CONTEXT_ATTRIBUTE);
		boolean isCSSHandler = false;
		if (null != rsHandler) {
			ClientSideHandlerGenerator generator = rsHandler.getClientSideHandler();
			// If this is not a pointer to the same generator it means this
			// generator is the javascript one,
			// so we add CSS bundles to the script
			if (this != generator) {
				variants = rsHandler.getConfig().getGeneratorRegistry().resolveVariants(request);
				sb.append(";JAWR.loader.cssbundles = [");
				sb.append(generator.getClientSideBundles(variants, useGzip));
				sb.append("];\n");
			} else
				isCSSHandler = true;

			// Add the mapping for css resources
			sb.append("JAWR.loader.cssmapping='").append(getPathPrefix(request, rsHandler.getConfig())).append("';\n");
		}
		// End self executing function
		sb.append("})();");

		// Appends extra functions for debug mode
		if (this.config.isDebugModeOn()) {
			sb.append(debugScriptTemplate.toString()).append("\n");
		}

		// The global bundles are already sorted and filtered by the
		// bundleshandler
		for (JoinableResourceBundle bundle : globalBundles) {
			String func = isCSSHandler ? "JAWR.loader.style(" : "JAWR.loader.script(";
			sb.append(func).append(JavascriptStringUtil.quote(bundle.getId())).append(");\n");
		}

		// Minify the result
		if (!this.config.isDebugModeOn()) {
			JSMinPostProcessor p = new JSMinPostProcessor();
			try {
				sb = p.minifyStringBuffer(sb, config.getResourceCharset());
			} catch (IOException | JSMin.JSMinException e) {
				throw new BundlingProcessException("Unexpected error creating client side resource handler", e);
			}
		}
		return sb;
	}
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()
                )
            );
        }
    }
379612
public void execute(String name, Reader sqlCode, PrintWriter out) throws Exception {
        runScript(name, sqlCode, out);
    }
421692
public static <T> T executeGroovyShellScript(final String script,
                                                 final Map<String, Object> variables,
                                                 final Class<T> clazz) {
        try {
            val binding = new Binding();
            val shell = new GroovyShell(binding);
            if (variables != null && !variables.isEmpty()) {
                variables.forEach(binding::setVariable);
            }
            if (!binding.hasVariable("logger")) {
                binding.setVariable("logger", LOGGER);
            }
            LOGGER.debug("Executing groovy script [{}] with variables [{}]", script, binding.getVariables());

            val result = shell.evaluate(script);
            return getGroovyScriptExecutionResultOrThrow(clazz, result);
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
        return null;
    }
1259553
Object executeScript(String jsScript, Map<String, Object> parameters) {
    EntityType entityType = entityTypeFactory.create("entity");
    Set<String> attributeNames = parameters.keySet();
    attributeNames.forEach(key -> entityType.addAttribute(attributeFactory.create().setName(key)));
    if (attributeNames.iterator().hasNext()) {
      entityType.getAttribute(attributeNames.iterator().next()).setIdAttribute(true);
    }
    Entity entity = new DynamicEntity(entityType);
    parameters.forEach(entity::set);
    return jsMagmaScriptEvaluator.eval(jsScript, entity);
  }
503615
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);
  }
189020
@Help(
    help =
        "Executes a script at runtime for a VNFR of a defined VNFD in a running NSR with specific id"
  )
  public void executeScript(final String idNsr, final String idVnfr, String script)
      throws SDKException {
    String url = idNsr + "/vnfrecords" + "/" + idVnfr + "/execute-script";
    requestPost(url, script);
  }
1171075
function run(script, args) {

  var res, result, name;
  try {
    res = this.exec.apply(this, [script].concat(args));
    result = res.result;
    //console.dir(result);
    //console.dir(result instanceof Error);
    if(typeof result === 'function') return;
    if(result === undefined) {
      throw new Error('undefined return value is not allowed');
    }else if(
      result !== null
      && !(result instanceof String)
      && !(result instanceof Error)
      && typeof result === 'object'
      && !Array.isArray(result)) {
      throw new Error('object return value is not allowed');
    }
  }catch(e) {
    name = res && res.name ? res.name : 'user_script';
    result = new StoreError(
      null, 'error running script (call to %s): %s', name, e.message);
  }

  if(typeof result === 'boolean') {
    result = Number(result);
  }

  // TODO: check the return value is not an object!!!
  //
  var err = (result instanceof Error);
  if(err) result = result.message;

  process.send({err: err, data: result, str: (result instanceof String)});
}
1078866
protected void executeScript(String scriptPath) {
        URL scriptUrl = null;
        try {
            if (scriptPath.startsWith("classpath:")) {
                String script = scriptPath.substring("classpath:".length());
                scriptUrl = ClassUtil.getResource(script);
                if (scriptUrl == null) {
                    log.warn("Script '{}' not found!", scriptPath);
                }
            } else {
                File file = new File(scriptPath);
                if (file.exists()) {
                    scriptUrl = file.toURI().toURL();
                } else {
                    log.warn("Script '{}' not found!", scriptPath);
                }
            }

            // execute the script
            if (scriptUrl != null) {
                executeScript(scriptUrl);
            }

        } catch (Exception e) {
            log.error("Failed to parse '{}' as a url", scriptPath);
        }
    }
474033
function(url) {
  var done = _onImportScript(url)
  loadScript(
    url,
    function runScript(err, code) {
      if (err) return done(err)
      executeJailed(code, url, done)
    }
  )
}