-
|
I'm trying to write a user script in Java. The script runs when I invoke it from the Script Manager GUI, but when I try to add the same script to a headless analysis session, it fails. Here are the errors:
I thought maybe there were some semantical differences, so I paired the script down to a single output line, but I still get the above error. I tried several times to delete //Test script
//@author Henri Hein
//@category Userscripts
//@keybinding
//@menupath
//@toolbar
import ghidra.app.script.GhidraScript;
public class GPTest extends GhidraScript {
public void run() throws Exception {
if (currentProgram == null) {
println("No program loaded. ");
return;
}
println("QGPGhidraInformation_FD729E34 BEGIN " + currentProgram.getExecutablePath());
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 12 replies
-
|
What Ghidra version are you using? Is your GUI Ghidra and your headless Ghidra running off the same installation? |
Beta Was this translation helpful? Give feedback.
-
|
My Ghidra version is 12.0.4. Yes, I'm using the same Ghidra installation for the two use cases. |
Beta Was this translation helpful? Give feedback.
-
|
C:\t might be interpreted as a Tab escape sequence, try |
Beta Was this translation helpful? Give feedback.
-
|
What is the actual command line you're running when you try to invoke the script with |
Beta Was this translation helpful? Give feedback.
-
|
From support/analyzeHeadlessREADME -postScript <ScriptName.ext> []* This parameter expects the script name only; do not include the path to the script. The Headless Analyzer searches specific default locations for the named script, but additional script director(ies) may also be specified (see the -scriptPath argument for more information). |
Beta Was this translation helpful? Give feedback.
It looks like (and I didn't actually know this) Python/PyGhidra scripts do not require the
-scriptPathto be set for out-of-tree scripts, but Java scripts do. So @henrihein I would think this is the issue. Change your command to:TIL Python scripts don't need to specify the scriptPath.