Cancelling a print job from the Linux command line

Tags:
CUPS
Linux
Printing from Linux
Red Hat Enterprise Linux
I'm trying to cancel a print job in Linux from within an interface script, but I'm not having much luck.  My aim is to move the job to another printer by "lp"ing the job to another device, then cancel the primary print job.  Here is my modest script:



job="$1"

user="$2"

title="$3"

numcopies="$4"

options="$5"

filename="$6"

countme=0

countme=$(grep -c saj $filename)

#echo $countme $filename > /testit/done.txt if [ $countme -gt 0 ] then

     echo "it contains Saj $1 $2 $3 $6 philsprinter-$job" > /testit/done.txt

      lp -dkpicking $filename

      sleep 2

      cancel "$job"

      exit 0

else

#     echo "it does not contain Saj" > /testit/done.txt

      cat "$filename"

fi 



 

The logic appears to work but I can't cancel the original print request.  Is it because the job is too far down the road of printing?  Or is it a user permission thing?Your advice would be appreciated.  I'm using Red Hat Linux and CUPS.



Software/Hardware used:
Linux, CUPS

Answer Wiki

Thanks. We'll let you know when a new response is added.

Why do you ‘wait’ 2 sec with the cancel?
If yo are testing to print small jobs, they will have gone “into the printer” before your cancel command is fired.
Why don’t you start with that, and then do the more time-consuming lp command?

Just an idea ….

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following