Page 1 of 1

How to access shell script return value in hazel

PostPosted: Wed Apr 17, 2024 9:18 pm
by mevans
I read the shell script docs. I see that the $1 is passed to a script as the filename that caused the Hazel rule to be executed. However I cannot find any information on how the output (stdout perhaps?) can be read or used by the Hazel rule. How does that work?

Re: How to access shell script return value in hazel

PostPosted: Thu Apr 18, 2024 8:22 am
by Mr_Noodle
Return value determines success or failure but you cannot read it outside of that. There is no support currently to read stdout. What you could do is use AppleScript. You can then have it call the shellscript, interpreting any output and then providing the record that can be passed back.

Re: How to access shell script return value in hazel

PostPosted: Thu Apr 18, 2024 12:25 pm
by mevans
Mr_Noodle wrote:Return value determines success or failure but you cannot read it outside of that. There is no support currently to read stdout. What you could do is use AppleScript. You can then have it call the shellscript, interpreting any output and then providing the record that can be passed back.


That's a great suggestion since I will be doing AppleScript in addition to my python shell script.

I thought of another solution -- have my script write its output to a temporary file whose name is "well known" and based on the filename passed into the script. (Original filename with extra ".csv" or ".tmp" extension.)