Shell Script on M1 Mac/Monterey

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

Moderator: Mr_Noodle

Shell Script on M1 Mac/Monterey 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
Last edited by pluralog on Thu Nov 04, 2021 2:09 pm, edited 1 time in total.
pluralog
 
Posts: 11
Joined: Tue Oct 23, 2018 8:15 am

Re: Shell Script on M1 Mac/Monterey Thu Nov 04, 2021 1:59 pm • by Mr_Noodle
Try using a full path for 'tesseract' and see if that works.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Shell Script on M1 Mac/Monterey 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.
pluralog
 
Posts: 11
Joined: Tue Oct 23, 2018 8:15 am

Re: Shell Script on M1 Mac/Monterey 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.
pluralog
 
Posts: 11
Joined: Tue Oct 23, 2018 8:15 am

Re: Shell Script on M1 Mac/Monterey Thu Nov 04, 2021 3:36 pm • by Mr_Noodle
Meant the full path for the tesseract program, wherever you have that installed.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Shell Script on M1 Mac/Monterey 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.
pluralog
 
Posts: 11
Joined: Tue Oct 23, 2018 8:15 am


Return to Support