How to get a response of file printing job to user from printer using CUPS in linux

440 views Asked by At

I am trying to print a file in remote server through CUPS command , User needs to know the status of job status. How to get a response from that. Here is my code :

 #!/usr/bin/perl
 my $response = system("lpr -P laserJet123   -o raw -T test_womargin abc.txt");
 print $response; 
1

There are 1 answers

0
user3829086 On

$? returns the response status of system command.

system("lpr -P laserJet123   -o raw -T test_womargin abc.txt");
if ($? == -1) {
print "failed to execute: $!\n";
}
elsif ($? & 127) {
printf "Job failed with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
}
else {
 printf "Job exited with value %d\n", $? >> 8;
}