Ask Different Asked by cep on February 12, 2021
I try to implement these two very simple commands in an Automator service to be run by a keyboard short (takes a screenshot and OCRs it):
screencapture -i /tmp/tesseract.png
tesseract /tmp/tesseract.png stdout|tr -d \f|pbcopy
This works great when I execute these commands in the Terminal, but not when I make it an Automator service (sorry this is in German).
I don’t understand: Why does it work in the one case and not in the other? Does it have anything to do with tesseract?
Any executable that is not within the PATH
passed to the Run Shell Script action, which is /usr/bin:/bin:/usr/sbin:/sbin
, you must use the fully qualified pathname of the executable.
In this case, e.g. /path/to/tesseract
You should be able to get its path in Terminal using:
which tesseract
As tesseract
is not a default of macOS, it may be in /usr/local/bin/
, however which tesseract
should report its fully qualified pathname.
Instead of using the fully qualified pathname, or in conjunction with, you can also add a PATH
statement to the top of the Run Shell Script action, e.g. for a bash
shell:
PATH="${PATH}:/usr/local/bin/"
You could also just substitute everything to the right of the =
sign for what the output in Terminal, e.g. echo $PATH
is. Then the Run Shell Script action has the same PATH
as Terminal.
Answered by user3439894 on February 12, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP