Problem running shell script

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

Moderator: Mr_Noodle

Problem running shell script Fri Dec 10, 2021 6:50 am • by albrox
Hi,

I am trying to OCR files in a folder with ocrmypdf.

I have installed ocrmypdf via homebrew. And have set up, as read in other threads and forums, the script like this:

Code: Select all
/opt/homebrew/Cellar/ocrmypdf -l deu+eng "$1" "$1" --skip-text


Running
Code: Select all
ocrmypdf -l deu+eng "$1" "$1" --skip-text
in a terminal (replacing $1 with filename) works fine. Running the same code in Hazel says, it does not find ocrmypdf. So I added the full path "/opt/homebrew/Cellar/ocrmypdf". This finds ocrmypdf, but says: permission denied.

Is this a general problem with homebrew? Or is it Hazel? Does anyone have a solution? For the shell I am using: "/bin/zsh"

Thank you so much!
albrox
 
Posts: 9
Joined: Fri Dec 10, 2021 6:47 am

Re: Problem running shell script Fri Dec 10, 2021 9:40 am • by Mr_Noodle
Can you post the full text of the error in the logs?
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Problem running shell script Fri Dec 10, 2021 11:07 am • by albrox
2021-12-10 16:05:46.338 hazelworker[62033] [Error] Shell script failed: Error processing shell script on file /Users/USERNAME/Desktop/TEST/ENERGY STAR.pdf.
2021-12-10 16:05:46.338 hazelworker[62033] Shellscript exited with non-successful status code: 126
2021-12-10 16:05:46.338 hazelworker[62033] DEBUG: Tapping error retry sequence
2021-12-10 16:05:46.338 hazelworker[62033] DEBUG: Writing out DB file for /Users/USERNAME/Desktop/TEST to path: /Users/USERNAME/Library/Application Support/Hazel/16747233-10730892.hazeldb
2021-12-10 16:05:46.339 hazelworker[62033] DEBUG: Directory /Users/USERNAME/Desktop/TEST processed in 0.029672 seconds
2021-12-10 16:05:46.339 86Z3GCK4MF.com.noodlesoft.HazelHelper[30981] DEBUG: Checking events for path /Users/USERNAME/Desktop/TEST, folder TEST
2021-12-10 16:05:46.339 hazelworker[62033] DEBUG: Sleeping
2021-12-10 16:05:54.347 hazelworker[62033] DEBUG: Could not read Mail preferences.
2021-12-10 16:05:54.348 hazelworker[62033] DEBUG: About to process directory /Users/USERNAME/Desktop/TEST
2021-12-10 16:05:54.354 hazelworker[62033] ENERGY STAR.pdf: Rule Rechnung aufbereiten matched.
2021-12-10 16:05:54.355 hazelworker[62033] DEBUG: Got error last time. Re-trying actions.
2021-12-10 16:05:54.382 hazelworker[62033] DEBUG: == script output ==
/var/folders/d5/lsywl4qj6c3ewcg2ml8ryx240000gn/T/hazelworker-62033/hazelscript.sh:1: permission denied: /opt/homebrew/Cellar/ocrmypdf

== End script output ==
albrox
 
Posts: 9
Joined: Fri Dec 10, 2021 6:47 am

Re: Problem running shell script Mon Dec 13, 2021 9:02 am • by Mr_Noodle
Try giving Hazel full disk access:

- Launch System Preferenecs
- Go to Security & Privacy
- Go Privacy
- Select Full Disk Access
- Click the lock in the lower left to allow changes. Enter password when prompted.
- If Hazel is not in the list, add it. If it is, make sure it is checked.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Problem running shell script Thu Dec 16, 2021 8:28 am • by albrox
Thank you for your reply. Still getting: permission denied: /opt/homebrew/Cellar/ocrmypdf
albrox
 
Posts: 9
Joined: Fri Dec 10, 2021 6:47 am

Re: Problem running shell script Thu Dec 16, 2021 10:29 am • by Mr_Noodle
Can you check the permissions on /opt/homebrew/Cellar/ocrmypdf? Also, if you do "which ocrmypdf" in Terminal, what does it show?
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Problem running shell script Wed Dec 22, 2021 8:55 am • by albrox
"which ocrmypdf" gives -> /opt/homebrew/bin/ocrmypdf

"ls -l /opt/homebrew/bin/ocrmypdf" gives -> lrwxr-xr-x 1 USERNAME admin 38 10 Dez 06:39 /opt/homebrew/bin/ocrmypdf -> ../Cellar/ocrmypdf/13.1.0/bin/ocrmypdf
albrox
 
Posts: 9
Joined: Fri Dec 10, 2021 6:47 am

Re: Problem running shell script Wed Dec 22, 2021 9:46 am • by Mr_Noodle
Ok, so it's a symbolic link to another location. Can you do 'ls' on /opt/hombrew/Cellar/ocrmypdf/13.1.0/bin/ocrmypdf ?
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Problem running shell script Tue Jan 04, 2022 1:08 am • by albrox
Not sure if I did it right. But that is the result.

Code: Select all
ls: /opt/hombrew/Cellar/ocrmypdf/13.1.0/bin/ocrmypdf: No such file or directory



Though I can ls on
Code: Select all
/opt/hombrew/Cellar/ocrmypdf/13.1.0/bin/
. With
Code: Select all
ocrmypdf
as result. So the file is in there, I guess.
albrox
 
Posts: 9
Joined: Fri Dec 10, 2021 6:47 am

Re: Problem running shell script Tue Jan 04, 2022 10:49 am • by Mr_Noodle
The symbolic link is there but what the symbolic link points to is missing. You'll need to look into that.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Problem running shell script Sat Jan 08, 2022 10:50 am • by albrox
I am not a pro. But why does
Code: Select all
ocrmypdf -l deu+eng "$1" "$1" --skip-text
work then in the terminal?
albrox
 
Posts: 9
Joined: Fri Dec 10, 2021 6:47 am

Re: Problem running shell script Mon Jan 10, 2022 11:09 am • by Mr_Noodle
Try specifying the full path just to make sure we are comparing apples to apples.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Problem running shell script Mon Jan 10, 2022 3:37 pm • by albrox
by typing: /opt/hombrew/Cellar/ocrmypdf/13.1.0/bin/ocrmypdf into the terminal?

(sorry :roll: )
albrox
 
Posts: 9
Joined: Fri Dec 10, 2021 6:47 am

Re: Problem running shell script Tue Jan 11, 2022 9:16 pm • by Mr_Noodle
Yes, does that work? If not, then do "which ocrmypddf" to see what the actual path is.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Problem running shell script Sun Jan 16, 2022 2:25 am • by albrox
which ocrmypdf gives: "/opt/homebrew/bin/ocrmypdf"

So now I have used that path in Hazel. It seems to work from Hazel's side. Now giving me the error:

" raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tesseract'"

that seems to be ocrmypdf's problem. So I think from Hazel's side all is good now! Thank you very muc!
albrox
 
Posts: 9
Joined: Fri Dec 10, 2021 6:47 am


Return to Support