Repository navigation
[Question/Bug]: STDIN in trigger plugin problematic?! #26
Replies: 5 comments 1 reply
|
Moving this to discussions... |
|
Parsing JSON in shell is very tricky, but it can be done! Here's how I've done it: My event has 3 user field parameters defined:
And my shell script looks like this: #!/bin/bash
IFS=$'\t' read -r width height codec < <(
jq -r '[.params.width, .params.height, .params.codec] | @tsv'
)
echo "WIDTH: $width"
echo "HEIGHT: $height"
echo "CODEC: $codec"Job output:
Now, doing it as a TRIGGER Plugin is even trickier, because in that case you get an array of objects, where you have to decide launch or no-launch for each item, then send back another JSON array. I am not sure how to do THAT with shell and jq. Ref: https://github.com/pixlcore/xyops/blob/main/docs/plugins.md#trigger-plugins |
|
I think the problem is that the JSON passed to STDIN includes the bash script code as well which jq cannot parse then. Steps to reproduce:
Error displayed in xyops is something like line 3 cannot be parsed (which is line 3 of the STDIN which is the bash code "ls"). Btw is there a way to better debug trigger plugins during development? Even in error cases I cannot see the output of the plugin in the log or the job itself, makes it hard to debug. I already added debug lines to write output to disc but this is annoying :D ... and finally: do not get me wrong I really appreciate the work and dedication you put into this project. I really <3 cronicle and the new version as it is really stable and simplifies my home network a lot! |
|
Hi, thanks for your effort. I already switched to python as I was not able to get it to work. But if everything works as expected we can close this discussion, I just wanted to ensure there is no bug or unwanted behavior. In python it worked like a charme for me already created some trigger plugins I am happy to share as soon as the marketplace is open :) |





Uh oh!
There was an error while loading. Please reload this page.
Is there an existing issue for this?
What happened?
I tried writing a trigger plugin in shell, but I did not manage to parse the STDIN input I get.
There were always parsing errors with jq due to special hidden characters or line endings.
In the end I used python which worked like a charme.
So my question is: Did anyone successfully wrote a shell based plugin parsing the STDIN output?!
Operating System
Ubuntu-22.04
Node.js Version
latest
xyOps Version
0.9.72
Server Setup
Single Conductor
Storage Setup
Default (SQLite + Filesystem)
Relevant log output
Code of Conduct
All reactions