system.report.executeAndDistribute()... Does it work in Linux?

Hello, I’ve sent this to support yesterday and no response yet… Just my totalcare notice that it’s due end of March… Kinda frustrating…

Anyway,I’ve tried :

system.report.executeAndDistribute(path=“Ticket DO2”, project=“NotcheuseSMI”, action=“print”, actionSettings = {“primaryPrinterName”:“SMITicket”}) on a Tag Change script. I have no error but it doesn’t print nothing. on my gateway server, nothing in print queue.

I’ve tried the script from Printing report to networked printer I’ve modified it to put the output to temp file because I don’t think there is a console for gateway scripts as follow:

from javax.print import PrintServiceLookup as PSL

printerList = PSL.lookupPrintServices(None, None)
defaultPrinter = PSL.lookupDefaultPrintService()

tempFile = system.file.getTempFile(“txt”)

for printer in printerList:
system.file.writeFile(tempFile, printer.getName(), 1)

The file was empty. The only possible reason that I can see is that the printer was just created and I need to reboot server or service? Since it’s a pain to reboot this server, I want to ask first, if it will help my cause. Or is there another reason?

To answer the title of your question, yes executeAndDistribute works on Linux.

Based on the text of your question, the real issue is that Java isn’t seeing your printer. After googling for a bit, it looks like you might be hitting a known Java issue – the work around is to reboot, open the printers control panel, and then start Ignition. Unfortunately, if Java can’t see the printer, then neither can Ignition. :\

Reboot and/or restarting the program didn’t fix it. What is happening is that JAVA needs ‘/usr/bin/lpr’ as stated for this application (What ever it is.) :
https://www.mathworks.com/matlabcentral/answers/102504-why-do-i-receive-a-java-printerioexception-when-i-try-to-print-from-of-one-of-the-desktop-windows-on?requestedDomain=true

So it’s either the lpr is somewhere else, and you need to create a symlink lpr to the actual location of lpr, or in my case, just nowhere to be found. Doing sudo apt-get install lpr will install a lpr, but that one will not work, as stated here:

So the fix was sudo apt-get install cups-bsd

2 Likes

To add to this solution, further down the road you might get a problem with the printer giving you a media error when you try to print. The solution is to force the driver to RAW with:

sudo lpadmin -p <PrinterName> -m raw

then in cups http://localhost:631/admin
modify the printer with the Zebra ZPL driver again.

In some instance I had to reboot the server, and sometimes not. Guess it’s because I haven’t cancelled the print job in the queue before starting the procedure.

1 Like