What is your IM version and platform? Did you follow my instructions on my web site to properly install the script and be sure your IM convert is in your PATH environment variable and change the location of dir to /tmp? How big is your Tiff? Does it have multiple layers? My script does not handle multiple layers.

I have never had this problem? Can you provide your input image? You can post to some place such as dropbox.com and put the URL here. Or send it to me directly (fmw at alink dot net).

It seems to be related to

"unable to persist pixel cache `./textcleaner_1_30964.mpc'""

But I do not know exactly what that means. This seems to be related to the first convert from the infile to .mpc format.

I might know more once I have your image and know your IM version and platform and how IM was installed and if you followed my instructions on my home page.

One good test would be to see if you can run any of my examples on the textcleaner page and whether you get errors or not. That would tell me if it is your environment, installation of IM or just your image.

I use "Version: ImageMagick 6.9.1-9 Q8 armle 2016-05-31" on a ARM Linux system.
I checked your "Pointers for use:" and found no mistakes. But I think this is confirmed because the script is running by replacing $tmpA1 by $infile like descripted above.
Changing the $dir to /tmp does ether show no positive results

The picture file is a scanned text document in tiff format of 8MB, but I also have checked a smaller picture of a few KB with the same neg. result.

Your system is having trouble or missing grep. MCP is IM's internal format, so it cannot be unknown. Someone else reported a similar issue, but I cannot reproduce it and don't recall if it is related to grep or was some other problem. But they got a similar loss of the mpc or corresponding cache image. Send me your image so I can test with it. It could also be a Q8 (vs Q16) issue with what information %r is providing. I will have to recompile as Q8 and see what is being presented. Does you tif file have transparency or an alpha channel. That might cause %r to report GrayA. I will have to check and get back.

It also works fine for my IM 6.9.1.9 Q8 compile. So my guess is that your system has a different operation for grep or pipe. I am not sure what to suggest other than the tests in my earlier posts or to try some of the other grep flags.

If you can reproduce the issue from my test commands earlier, then we can report that on the Bugs forum and see what the developers suggest.

the files were created (tif,mpc,cache)
After the execution of the convert command the cache file is gone.
The return value is empty "typegray="
Is can not the gep command because just executing the command "convert logo.mpc -format '%r' info:" returns "PseudoClass sRGB" and afterwards the cache file is gone.