#StackBounty: #ssh #cups #exit-status #printer Unable to detect a failed print on a remote system using ssh

Bounty: 200

Below is my code on linux that prints a PDF on a remote MACOS system.

echo "Printing ssh -p 3335 ibrahimince@localhost 'lp -d Brother_HL_L2350DW_series $HOMEDIR/Printed/$NEWFILE'";

echo "Remote File details are:"
ssh -p 3335 ibrahimince@localhost "ls -ltr $HOMEDIR/Printed/$NEWFILE"

until ssh -p 3335 ibrahimince@localhost "lp -o media=A5 -d Brother_HL_L2350DW_series $HOMEDIR/Printed/$NEWFILE" >/home/system/efendibey.de/invoices/send4print/printererror.log 2>&1

echo "Exit Code of the command was: $?"
echo "Send email that there is an issue printing invoice for the below file. Issue is: `cat /home/system/efendibey.de/invoices/send4print/printererror.log`"
ls -ltr $FILE >>/home/system/efendibey.de/invoices/send4print/printererror.log

mail -s "PRINTER SERVICE FAIL ALERT. PLEASE CHECK YOUR PRINTER!!" mohtashim@digiklug.com < /home/system/efendibey.de/invoices/send4print/mailbody.txt
sleep 20


echo "Print successful. Deleting $FILE"
rm $FILE;


Here are the logs for a particular print online_delivery_10001333.pdf.

Printing ssh -p 3335 ibrahimince@localhost 'lp -d Brother_HL_L2350DW_series /Users/ibrahimince/Printed/online_delivery_10001333.pdf'
Remote File details are:
-rw-r--r--  1 ibrahimince  staff  11496 Aug  2 19:29 /Users/ibrahimince/Printed/online_delivery_10001333.pdf
Print successful. Deleting /home/system/efendibey.de/invoices/send4print/online_delivery_10001333.pdf

The logs say that the print was successful and the return code was 0(successful).

But, the print actually failed, and below is the snapshot of the same.

Error: Gestoppt - Can't open "/private/var/spool/cups/d02183-001.

enter image description here

How can I refine my code so to make sure the print was actually successful?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.