macOS and USB printer reset issue
Stupid! Stupid! Stupid! as in the letter from an insurance company in The Rainmaker, except in this case it's completely justified. I have an HP Laser Jet 5 printer (superior print quality) connected via USB to my MacBook Pro (9,2., mid 2012) running High Sierra 10.13.6. After each print job I must disconnect and reconnect the USB cable from the machine in order to print the next job. I discovered that this actually works quite by accident after many hours of troubleshooting failed print jobs. If I simply attempted to print a subsequent job the printer halted before anything emerged from the printer. The messages varied from such as: "8% of page finished", or "waiting for printer to become available", but nothing I could do would get it to complete the print task. I tried pause and restart ad nauseam, to no effect. Deleting the job from the queue didn't really delete the entry from the hidden queue buffer deep inside macOS (more on that below). Resetting the print system and re-adding the printer also did not work as even after doing these and re-initiating the job, the print system reported either the printer was offline or the job appeared in the queue waiting for the printer to become available even though the printer itself reported it was ready to print. I suspect the previous job was still in the hidden buffer in a paused state and thus was blocking the job waiting in the visible queue. And to add insult to injury, if I rebooted the machine the stalled print job resumed correctly after reboot completed. Go figure... The only thing that works, and it works perfectly every time is to unplug the USB printer cable and reinsert it. So, pending the arrival of a new Brother wi-fi printer, I unplug and re-plug between print tasks. Man, when you are printing client tax returns during tax season, that is a real pain. I used to have this printer attached to a Windows machine running XP as a print server, until a recent lightning strike fried that machine and a wi-fi router, and it never failed to print from my MBP or my wife's Windows laptop. It would appear that Apple in macOS HS just does not know how to effectively manage USB printers, perhaps not in any version of macOS using a USB connection, since Apple and USB just do not mix well (the ubiquitous and unwelcome improper disk eject problems).
That was background: now my question; beneath every GUI application is the macOS API. There must be a tool or a set of API commands available from the command line that can be used to manage printers and print jobs. If I knew what commands macOS uses to manage printers I could probably write a shell or Perl script to do the equivalent of unplugging and re-plugging my printer; something like umount and mount for printer devices; maybe that's it - umount and mount! Or, perhaps a command to empty the internal buffer. Have any of you experienced this problem and solved it in a different way? Or, do any of you know what command or commands would be appropriate from the command line? Thanks in advance for any help offered.
MacBook Pro 13″, macOS 10.13