Tekki / sql-ledger

:books: The most advanced SQL-Ledger version.
GNU General Public License v3.0
35 stars 14 forks source link

Internal Server Error when printing with CUPS #68

Open sse450 opened 1 month ago

sse450 commented 1 month ago

Installed CUPS server on the SL machine. Adjusted System--Workstations accordingly. SL prints fine. But following each print, I get this error on the browser: Screenshot from 2024-05-30 09-59-47

Apache logs report this: [Thu May 30 09:57:35.255655 2024] [cgid:error] [pid 152106:tid 152266] [client 10.10.1.44:40054] malformed header from script 'ap.pl': Bad header: request id is MFC-L2715DW-5 (0, referer: http://10.10.1.16/finans/ap.pl?action=edit&id=10470&path=bin/mozilla&login=mufit@onart2024&callback=ap.pl%3faction%3dtransactions%26direction%3dDESC%26oldsort%3dtransdate%26till%3d%26outstanding%3d%26path%3dbin%2fmozilla%26login%3dmufit%40onart2024%26summary%3d1%26title%3d%26helpref%3d%26vendor%3dArkas%2520Otomotiv--10106%26open%3dY%26closed%3dY%26l_transdate%3dY%26l_invnumber%3dY%26l_description%3dY%26l_name%3dY%26l_amount%3dY%26l_paid%3dY%26sort%3dtransdate

Despite the error, SL is working fine. Just wanted to report.

Tekki commented 1 month ago

"request id is MFC-L2715DW-5" looks like the output of a lpr print command. Use lp instead. Example:

lp -s -d Kyocera-PA5000 -o media=Tray1
sse450 commented 1 month ago

Actually, I had used just lp command without any option thereafter. I tried with -s , -d , -o options. All of them generated Internal Server Error.

Last time, I wanted to try lpr . It worked. I don't know why, but no any server error with lpr.

Thank you.

Tekki commented 1 month ago

Actually, I had used just lp command without any option thereafter. I tried with -s , -d , -o options. All of them generated Internal Server Error.

-s means silent, -d destination and -o option. If you still have errors when the -s parameter is set, you have to check the apache log again. The source of the error is the output of the shell command that gets redirected to the web server.

Last time, I wanted to try lpr . It worked. I don't know why, but no any server error with lpr.

Maybe because it produces no output?

sse450 commented 1 month ago

Update: Screenshot from 2024-06-03 14-32-58 This command sometimes prints without error, but sometimes with error on the screen and Apache log. I know developers don't like this sort of answers. There must be a reason for this. But, I don't know.

This is from Apache log of the lp -s -d MFC-L2715DW -o media=tray1 :

[Mon Jun 03 14:30:50.791216 2024] [cgid:error] [pid 294491:tid 294650] [client 10.10.1.44:37142] malformed header from script 'ap.pl': Bad header: request id is MFC-L2715DW-24 (, referer: http://10.10.1.16/finans/ap.pl?action=edit&id=10261&path=bin/mozilla&login=admin@onart2024&callback=ap.pl%3faction%3dtransactions%26direction%3dDESC%26oldsort%3dtransdate%26till%3d%26outstanding%3d%26path%3dbin%2fmozilla%26login%3dadmin%40onart2024%26summary%3d1%26title%3d%26helpref%3d%26vendor%3dCan%2520G%25c3%25b6k%25c3%25a7e--10148%26open%3dY%26closed%3dY%26l_transdate%3dY%26l_invnumber%3dY%26l_description%3dY%26l_name%3dY%26l_amount%3dY%26l_paid%3dY%26sort%3dtransdate

lpr never produced error on screen and Apache log. At least so far.

Tekki commented 1 month ago

You can't be sure which command is executed if you have two printers with exactly the same name. The manpage for lp states:

-s Do not report the resulting job IDs (silent mode.)

So if the printing command produces an output like "request id is..." it seems the first one of your list is used. And if there is no error, the second one is used. The reason for such random behavior is that you don't know which object will be chosen if two of them have the same label.