script-server icon indicating copy to clipboard operation
script-server copied to clipboard

Option to pipe output of script to another program before output

Open chellige opened this issue 2 years ago • 3 comments

Hello,

Is there a way to pipe the output of a script with parameters at execution to another program?

script: python /tools/getdata.py parameters: --Name --City Then at execution, pipe the script and the parameters to JQ for json parsing

so effectively run this command line script

$ python /tools/getdata.py --Name Jones --City "New York"  | jq .

chellige avatar May 23 '23 20:05 chellige

If I were doing this I'd...

#!/path/to/python/shebang 1>/tmp/scriptout.tmp 2>&1

... Your script stuff here ...

$INFILE=cat /tmp/scriptout.tmp && rm /tmp/scriptout.tmp echo $INFILE | jq .

On Tue, May 23, 2023 at 4:31 PM chellige @.***> wrote:

Hello,

Is there a way to pipe the output of a script with parameters at execution to another program?

script: python /tools/getdata.py parameters: --Name --City Then at execution, pipe the script and the parameters to JQ for json parsing

so effectively run this command line script

$ python /tools/getdata.py --Name Jones --City "New York" | jq .

— Reply to this email directly, view it on GitHub https://github.com/bugy/script-server/issues/675, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HBI3UC4IXG5QXABCFVXYLXHUNBVANCNFSM6AAAAAAYMM6BAE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

MNeill73 avatar May 23 '23 21:05 MNeill73

Thanks for the suggestion, Unfortunately I'm not really getting what you are suggesting. Are you saying I should make a different script that is called by script-server and have that run the first script, capture the output and then send it to JQ?

chellige avatar May 23 '23 21:05 chellige

Hi @chellige, yes, script server does not support this. As @MNeill73 suggests, you have to create a wrapping script, which would do for script server instead.

bugy avatar May 24 '23 12:05 bugy