Strap and another application can talk to each other
Introduction
There are four methods for programmatically controlling a running Strap instance:
- Unidirectional exchange of information
-
Embedding in web pages: Web buttons perform some action on a specific Strap instance.
Clicking these web button launches a new Strap if no instance is running yet.
Otherwise the already running instance receives the program parameters and script commands.
2.
- Bidirectional
- Apps extend the functionality of Strap. Strap sends an XML document to the app and receives script commands. See Apps
- Sending commands via named pipes and retrieving information from Strap from an output file. This is explained here.
Here we explain bidirectional information exchange at runtime via named pipes and script output to employ Strap for another locally running application.
Running a script when Strap is started
An initial script which is interpreted at program start can be given with a command line parameter -script=file path.
It is possible to have more than one -script parameters.
A list of all script commands is printed with the program parameter -help=script.
Sending further script lines
Application can also communicate with Strap at runtime using a .
Strap will continuously interpreting text lines passing through the pipe.
The example below will work also on Windows even though named pipes are not supported
and the command mkfifo does not exist (which leads to an error message).
With the echo command in the 2nd line, testPipe will be created as a plain file.
Strap will observe all script files and if a file
increases in size, it will interpret the new text lines.
This is illustrated with the following Example for MacOS, Linux and Windows:
mkfifo testPipe
echo > testPipe
java -jar strap.jar -script=testPipe
In another terminal you can write script commands to testPipe:
echo aa_sequence hello , sequence1 >> testPipe
echo aa_sequence world , sequence2 >> testPipe
Obtaining Information from Strap
There are script commands to write information to an output file specified with the command line parameter -scriptOutput=file-path.
Author: christoph.gille |
|
charite |
. | de |