protected ResourceFile writePackageScriptContents(ResourceFile scriptFile, String pkg)
			throws IOException {
		String filename = scriptFile.getName();
		String className = filename.replaceAll("\\.java", "");

		//@formatter:off
		String scriptContents =
				"package " + pkg + ";\n\n" +
						"import ghidra.app.script.GhidraScript;\n\n" +

		    "public abstract class "+className+" extends GhidraScript {\n\n" +

		    "    static public int counter = 0;\n\n" +

		    	"    @Override\n" +
		    	"    public void run() throws Exception {\n" +
		    	"        message();\n" +
		    	"    }\n\n" +

	    		"    public void message() {\n" +
	    		"        println(\"\" + counter++);\n" +
	    		"    }\n" +
	    		"}\n\n";
		//@formatter:on

		writeStringToFile(scriptFile, scriptContents);

		return scriptFile;
	}
Run the last script by pressing the last script button and return output.

@param taskName name for the task listener
@return script output written to the console
@throws Exception on failure, e.g. timeout
Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/script/AbstractGhidraScriptMgrPluginTest.java