Page 1 of 1

Shell Script on M1 Mac/Monterey

PostPosted: Thu Nov 04, 2021 1:53 pm
by pluralog
Hello everybody,

after transferring from an intel based mac on Catalina to an M1 with Monterey, I have problems with one Hazel Rule including a shell script. The script ocrs a PNG after renaming it.

Image

Code: Select all
Rename with pattern ...
Run Shell Script embedded script: tesseract "$1" "$1" -l deu+eng PDF

The match works perfectly fine, the renaming works perfectly fine, the shell script errors.

The Log tells me:
Code: Select all
Error processing shell script on file /Users/name/Documents/Screenshots/screenshot.png.
Shellscript exited with non-successful status code: 1

Running the shell command by hand works perfectly fine too.
I ran
Code: Select all
"$1" > textfile.txt
, as a script. It gave back the full path "/Users/name/Documents/Screenshots/screenshot.png". Typing in
Code: Select all
tesseract "/Users/name/Documents/Screenshots/screenshot.png" "/Users/name/Documents/Screenshots/screenshot.png" -l deu+eng PDF
into terminal worked as planned and created a ocred PDF of the Screenshot.

So I guess the problem might has to do with user rights? But hazel and terminal have full disc access.

Would be glad if you can help.
Best regards

Re: Shell Script on M1 Mac/Monterey

PostPosted: Thu Nov 04, 2021 1:59 pm
by Mr_Noodle
Try using a full path for 'tesseract' and see if that works.

Re: Shell Script on M1 Mac/Monterey

PostPosted: Thu Nov 04, 2021 2:23 pm
by pluralog
Thanks.
Code: Select all
tesseract "/Users/name/Documents/Screenshots/$1" "/Users/name/Documents/Screenshots/$1" -l deu+eng PDF

Does not change anything. "Shellscript exited with non-successful status code: 127".

Running the shell command by hand works perfectly fine.
I ran
Code: Select all
echo "$1" > textfile.txt

as a Hazel script. It gave back the full path "/Users/name/Documents/Screenshots/screenshot.png". Typing in

Code: Select all
tesseract "/Users/name/Documents/Screenshots/screenshot.png" "/Users/name/Documents/Screenshots/screenshot.png" -l deu+eng PDF

into terminal worked as planned and created a ocred PDF of the Screenshot.

Re: Shell Script on M1 Mac/Monterey

PostPosted: Thu Nov 04, 2021 2:40 pm
by pluralog
I updated my old intel mac to Monterey and the script still works fine there. But I can't see any difference to my new M1.

Re: Shell Script on M1 Mac/Monterey

PostPosted: Thu Nov 04, 2021 3:36 pm
by Mr_Noodle
Meant the full path for the tesseract program, wherever you have that installed.

Re: Shell Script on M1 Mac/Monterey

PostPosted: Thu Nov 04, 2021 4:59 pm
by pluralog
Yes. Problem solved.
Thank you for your super fast help!

Code: Select all
/opt/homebrew/bin/tesseract "$1" "$1" -l deu+eng PDF

This did it for me.

Had to find the path in terminal.

Code: Select all
which tesseract

helped.