How to use the subprocess processor to invoke a script for each message
#1734
mihaitodor
started this conversation in
Show and tell
Replies: 1 comment
-
|
Very helpful, thanks Mihai! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
UPDATE: A new
commandprocessor has been introduced in v4.21.0 which can be used instead of this workaround. The instructions below can still be leveraged if you need to do something like this for thesubprocessinput or output.While the
subprocessprocessor is meant to start long-running commands, in some cases it's desirable to have it call a simple script which starts up, prints its output to stdout and exits for each message which flows through this processor. To achieve this, one can use a wrapper shell script like so:You'll also need to configure the
subprocessprocessor along with a downstreammappingprocessor like so (wherewrapper.shis the wrapper script above):Note: While encoding the data to base64 isn't mandatory, if your script emits any newline characters, then those have to be escaped somehow and this is a simple way of doing so. The
base64command behaves somewhat differently on various platforms and the above script is meant to be platform-independent. However, the| base64 | tr -d '\n\r' && echopart can be replaced with| base64on OSX and| base64 -w 0 && echoon Linux.Beta Was this translation helpful? Give feedback.
All reactions