How to access shell script return value in hazel

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

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?
mevans
 
Posts: 11
Joined: Sat Nov 17, 2018 9:50 pm

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.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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.)
mevans
 
Posts: 11
Joined: Sat Nov 17, 2018 9:50 pm


Return to Support