OK, I'm new to Linux so this may be some config problem of mine. I've installed pdfocr from the PPA and when I run the script it fails on the line:

sh "pdftoppm #{basefn+'.pdf'} >...