1

Following bash script interprets text in an image file and writes to a .txt file.

#!/usr/bin/env bash

LD_LIBRARY_PATH="/usr/local/lib"
export LD_LIBRARY_PATH

/usr/local/bin/tesseract /home/martin/work/textpic.png /home/martin/work/tesseract-out

When I run it from the terminal the tesseract-out.txt is created, but when I run it via custom keyboard shortcut nothing is written. I have ensured that the correct script is run by putting echo "test" > /home/martin/work/test.txt in it, which creates the file.

I have run sudo chmod 777 on tesseract in case it was some permission issue.

I have an inkling that tesseract needs some lib files which are not in paths when the script is run by shortcut, so I put these lines at the top of my script file (I know that some of the lib files it needs are in /usr/local/lib):

LD_LIBRARY_PATH="/usr/local/lib"
export LD_LIBRARY_PATH

But it did not do the the trick. How can I debug what is going wrong? If I could obtain some kind of error message somehow, that would go a long way.

My linux version:

DISTRIB_RELEASE=18.3
DISTRIB_CODENAME=sylvia
DISTRIB_DESCRIPTION="Linux Mint 18.3 Sylvia"
NAME="Linux Mint"
VERSION="18.3 (Sylvia)"
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME="Linux Mint 18.3"
VERSION_ID="18.3"
HOME_URL="http://www.linuxmint.com/"
SUPPORT_URL="http://forums.linuxmint.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/linuxmint/"
VERSION_CODENAME=sylvia
UBUNTU_CODENAME=xenial

The keyboard-shortcuts manager I use is the standard GUI one in Mint 18. Might be I could use something else to get a better error message?

keyboard-shortcuts GUI

EDIT:

I verified that all needed libs are in path by putting /sbin/ldconfig -N -v $(sed 's/:/ /g' <<< $LD_LIBRARY_PATH) > /home/martin/work/libs-in-path.txt at the bottom of my script and crosschecking the output against readelf -d /usr/local/bin/tesseract | grep NEEDED.

MyrionSC2
  • 111
  • 3
  • Not a solution, but you could try to put your command into a bash script and have your shortcut call that script instead. – Erik Dec 25 '19 at 19:26
  • @Erik Sorry if that was unclear, but that is what I have been doing. – MyrionSC2 Dec 25 '19 at 22:11

0 Answers0