My question was marked as duplicate: But I have not seen any solution in combination with the IF sattement I am trying to use. Any hints are welcome. Thanks
I am currently creating a small bash script to convert PDF documents to a searchable PDF via OCR. For that I am using "ocrmypdf"
My goal is to move the original PDF to a directory called "processed" in case everything is ok and in case of error to an "error" directory. -> this part of my script is working
To get the OK or ERROR I added the command execution to a IF statement.
Remark: the "echo_log" is a function that adds the passed text message to a LOG file.
if ocrmypdf $pdf_source $file
then
echo_log "OK OCR processing OK, move original file $pdf_source to $original_dir"
mv $pdf_source $original_dir
else
echo_log "ERROR OCR processing FAILED, move original file $pdf_source to $error_dir"
echo_log "ERROR Return values OCR process: $ret"
mv $pdf_source $error_dir
fi # OCR PDF/A Konvertierung
This is working fine so far, but I also like to add the error text of the executed command ocrmypdf to a variable to be able to store it within my logfile. How can I achieve this? At the moment the error text is just visible on the console.
Example of error text: ERROR - 1: page already has text! \u2013 aborting (use --force-ocr to force OCR) ERROR - 1: page already has text! \u2013 aborting (use --force-ocr to force OCR)
Thanks a lot Minxer