private GhidraScript getGhidraScript(String scriptName) throws Exception {
		ResourceFile scriptSourceFile = findScriptSourceFile(scriptName);
		GhidraScriptProvider provider = GhidraScriptUtil.getProvider(scriptSourceFile);

		if (provider == null) {
			throw new IOException("Missing plugin needed to run scripts of this type. Please " +
				"ensure you have installed the necessary plugin.");
		}

		PrintWriter errWriter = new PrintWriter(System.err);
		GhidraScript foundScript = provider.getScriptInstance(scriptSourceFile, errWriter);

		if (propertiesFilePath != null) {
			// Get basename, assume that it ends in .java, since we've already covered the
			// .class case
			String baseScriptName = foundScript.getScriptName();
			int lastIndexOf = baseScriptName.lastIndexOf(".");
			if (lastIndexOf > 0) {
				baseScriptName = baseScriptName.substring(0, lastIndexOf);
			}
			foundScript.setPropertiesFileLocation(propertiesFilePath, baseScriptName);
		}

		return foundScript;
	}
Runs the specified script with the specified state.

@param scriptState  State representing environment variables that the script is able
		to access.
@param script  Script to be run.
@return  whether the script successfully completed running
Ghidra/Features/Base/src/main/java/ghidra/app/util/headless/GhidraScriptRunner.java