I try to start a python program called ocrmypdf from a script or as a cronjob.
It works perfectly from the terminal,
pi@piscan:~ $ ocrmypdf
usage: ocrmypdf [-h] [--verbose [VERBOSE]] [--version] [-L FILE] [-j N] [-n]
[--flowchart FILE] [-l LANGUAGE] [--title TITLE]
[--author AUTHOR] [--subject SUBJECT] [--keywords KEYWORDS]
[-d] [-c] [-i] [--oversample DPI] [-f] [-s]
[--skip-big MPixels] [--tesseract-config TESSERACT_CONFIG]
[--pdf-renderer {auto,tesseract,hocr}]
[--tesseract-timeout TESSERACT_TIMEOUT] [-k] [-g]
input_file output_file
ocrmypdf: error: the following arguments are required: input_file, output_file
but from another shell it breaks for reasons I do not understand.
pi@piscan:~ $ sh ocrmypdf
sh: 0: Can't open ocrmypdf
pi@piscan:~ $ which ocrmypdf
/usr/local/bin/ocrmypdf
pi@piscan:~ $ sh $(which ocrmypdf)
import: unable to open X server `' @ error/import.c/ImportImageCommand/364.
import: unable to open X server `' @ error/import.c/ImportImageCommand/364.
from: can't read /var/mail/ocrmypdf.main
/usr/local/bin/ocrmypdf: 10: /usr/local/bin/ocrmypdf: Syntax error: "(" unexpected (expecting "then")
This is the executed code:
pi@piscan:~ $ cat $(which ocrmypdf)
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from ocrmypdf.main import run_pipeline
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(run_pipeline())