Predefined JSon format for controlled application execution
Note
This article refers to Drivve | Image version 9.2 or later
Controlled execution
A new feature introduced with version 9.2 is the ability to run applications or scripts (referred as executables) in a more controlled way. In older versions, you could use the Run Application feature only to run executables in an uncontrolled way, e.g. you could not retrieve result information of the executable.
In version 9.2 you can run an executable in a synchronous way which means, Drivve | Image will wait until the executable has ended and will validate its exit code. An exit code of zero will be considered success, any other will be a failure.
Support of JSon result
Additionally, the executable can support the Drivve | Image JSon format by returning a JSon (Java Script Object Notation) string described below. JSon is an open standard file format for data interchange. For more information on JSon see here.
If the executable supports the JSon format result information, it can control how Drivve | Image will handle the result and you can send notification emails, specify log output, etc.
JSon format specification
In order for the executable to support the Drivve | Image JSon result format, it has to return the following JSon sting before it ends (Note for developers: The executable must return a JSon string utf-8 encoded on Standard Out).
Example:
{
"Result":"SUCCESS",
"Message":"Test",
"Log":"Log",
"Error":"Error",
"ErrorDetail":"ErrorDetail",
"Notification":true,
"NotificationRecipient":"test@test.com",
"NotificationSubject":"Subject",
"NotificationBody":"Body"
}
Property |
Mandatory |
Possible value |
Description |
Result |
yes |
SUCCESS, WARNING, ERROR |
Result enumeration value as string. Possible values sent by the executable: SUCCESS: Successful execution WARNING: Successful in principle, but issues occurred. ERROR: Unsuccessful execution. |
Message |
no |
<any text> |
If set, it will be used as log output besides the Result value. If notification is send, this will be added to the email body. |
Log |
no |
<any text> |
If set it will be added to the log. |
Error |
no |
<any text> |
If set, will be added to the log. If notification is send, will be added to the email body. |
ErrorDetail |
no |
<any text> |
Further error details like the stack trace. If set, will be added to the log. |
Notification |
no |
true, false |
If set to true, an email notification will be sent. |
NotificationRecipient |
no |
email address |
If set use as notification recipient. Supports multiple email addresses separated by a semicolon. Overrides any default notification recipients. |
NotificationSubject |
no |
<any text> |
If set use as notification subject. Overrides any default subject. |
NotificationBody |
no |
<any text> |
If set use as notification body. Overrides any default body. |
Example of the simplest result JSon of a successful execution:
{
"Result": "SUCCESS"
}
Note
In order for the email notification to work, the email notification settings (SMTP server settings) have to be configured (Tools - Options - Notification).
In case the executable does not return a string or crashes, the following result will be set by Drivve | Image:
ERROR_NO_RESPONSE: Executable didn't return anything.
ERROR_RESPONSE_FORMAT: Executable didn't return a valid JSon response.
ERROR_EXECUTION_TIMEOUT: Executable didn't execute in the given time limits and was forcibly quit.
ERROR_ON_EXECUTION: Error was thrown while calling the executable.
Configuration of a controlled executable
- Within the Drivve | Image administration program, select the scan profile you want to set up.
- Click the Output button and then select the File Output
- On the bottom, right click the Run application button
- You will see the following dialog:
- Enter the path to the application or script and the command line parameters
- Activate the check box Wait until application exists and Application returns Drivve | Image JSon format
- Specify the timeout
- Click the Add button to add the application to the list
In order to test the execution, you can click the Execute button.