Writing Client Scripts
JEB supports the execution of Python scripts.
- Scripts should perform relatively small, light-weight actions
- They are written using the Python 2.7 syntax and features, and are executed by a Jython VM
Prerequisite#
A Jython stand-alone package is required to run scripts. JEB bundles the latest 2.7 package.
Legacy
If you are using JEB 2, download either Jython 2.7 (newer, slower to load) or Jython 2.5 (older and slimmer, faster to load) and drop it in your JEB scripts/ sub-directory.
Features#
Scripts can:
- use the standard JEB API
- use the Client API package
- if run within a client that implements the UI-API, use the JEB UI Client API
A client script implements the IScript interface. Upon execution, the script run() entry-point method is provided an IClientContext or derived object, such as an IGraphicalClientContext for UI clients, such as the official UI desktop client.
A Simple Script#
Here is the simplest of all scripts:
from com.pnfsoftware.jeb.client.api import IScript
class JEBSampleScript(IScript):
def run(self, ctx):
print('Hello, JEB version %s' % ctx.getSoftwareVersion())
print('- Arguments: %s' % ctx.getArguments())
print('- Base directory: %s' % ctx.getBaseDirectory())
Within the official desktop client, scripts can be executed via the File, Scripts menu item.
Remember that heavy-lifting operations (such as parsing or background event-driven tasks) should be implemented by back-end plugins in Java.
More scripts#
Check out our GitHub repository for more sample scripts.