tcf03 has asked for the wisdom of the Perl Monks concerning the following question:

I am looking at replacing a program that does nothing more than holds print jobs until a printer is free. An operator will then move the job to the desired queue. Has anyone attempted this before? Ive looked at some of the CPAN modules, none look too promising as far as queueing up jobs. Any clues as to where to start would be appreciated.

Thanks
Ted
--
"That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
  --Ralph Waldo Emerson

Replies are listed 'Best First'.
Re: Print queues
by Fletch (Bishop) on Nov 30, 2005 at 15:32 UTC

    I'd start by looking at what your OS' printing software can do natively before striking out on my own. For instance most Linux distros and OS X have CUPS which I'm sure has some sort of queue management.

      Its the hold queue thats creating the problem - I can move jobs between queues with cups, but getting it to just hold jobs is the hard part. That feature will be in the next release.
      Ted
      --
      "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
        --Ralph Waldo Emerson
Re: Print queues
by zentara (Cardinal) on Nov 30, 2005 at 16:52 UTC
    Net-Cups provides access to the whole Cups control system. I don't have any examples of controlling the queue, but it seems to do it automatically on my system....printing when the printer is available.

    I'm not really a human, but I play one on earth. flash japh
      In case anyone is looking for a easy snippet. :-)
      #!/usr/bin/perl use warnings; use strict; use Net::CUPS::Printer; use Data::Dumper; my @printers = cupsGetPrinters (); print "printers-> @printers\n"; my $printer = cupsGetDefault(); print "Default printer-> $printer\n"; my %options =(); my $jobid = cupsPrintFile($printer,"./$0",'Job1',\%options); print "jobid-> $jobid\n"; my $jobs = cupsGetJobs($printer,1,0); print "jobs-> $jobs\n"; print Dumper([$jobs]),"\n"; my $cancel = cupsCancelJob($printer, $jobid); print "cancel-> $cancel\n"; #my $jobs = cupsGetJobs($printer,1,0); #print "jobs-> $jobs\n"; #print Dumper([$jobs]),"\n"; my $user = cupsUser(); print "user-> $user\n"; exit;

      If I was interested in this problem, I probably would work out a way using Tk, Gtk2 or POE to keep a loop going, and build my own queue. Then runs cups on a different port, and have a custom daemon listening on port 631. The daemon can then loop, and monitor printer status, and assign jobs to the printers depending on some criteria you need.


      I'm not really a human, but I play one on earth. flash japh