redirect print job to file and process - how? - Questions

This is a discussion on redirect print job to file and process - how? - Questions ; I want to share a printer queue to receive a PCL job and save the job as a file. The name of the file containing the job is then passed to a process that manipulates the PCL, modifying certain pieces. ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: redirect print job to file and process - how?

  1. redirect print job to file and process - how?

    I want to share a printer queue to receive a PCL job and save the job as
    a file. The name of the file containing the job is then passed to a
    process that manipulates the PCL, modifying certain pieces. The “new”
    print job saved as a file and is optionally later sent to another queue
    for printing.
    I can do this in Windows fairly easily using a few tools such as RedMon.
    It seems that it would be even simpler to do this under Linux, but I am
    very new to Linux and I don’t know how, nor where to look for
    information as to how.
    I can locate the jobs in the queue, so I could presumably write a script
    to pick them out and do what I want to them. I am not sure if I can tell
    the spooler the job is gone, or whether I need to. I know that if I do
    it this way to Windows it will eventually cause problems.

    Thanks for advice.

  2. Re: redirect print job to file and process - how?

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Gary wrote:
    > I want to share a printer queue to receive a PCL job and save the job as
    > a file. The name of the file containing the job is then passed to a
    > process that manipulates the PCL, modifying certain pieces. The “new”
    > print job saved as a file and is optionally later sent to another queue
    > for printing.
    > I can do this in Windows fairly easily using a few tools such as RedMon.
    > It seems that it would be even simpler to do this under Linux, but I am
    > very new to Linux and I don’t know how, nor where to look for
    > information as to how.
    > I can locate the jobs in the queue, so I could presumably write a script
    > to pick them out and do what I want to them. I am not sure if I can tell
    > the spooler the job is gone, or whether I need to. I know that if I do
    > it this way to Windows it will eventually cause problems.


    There are likely many different ways to do this in Linux.

    FWIW, I'd tackle it this way:

    1) write a script to process the PCL and create a file

    2) create a printer queue and printer within the spooler that, instead
    of printing the data, runs the script on it. This is fairly easy to
    do in lpr or lprng (I've done it before), but I don't know if CUPS is
    as easy do set up.

    3) set up a process (you define how it is invoked) that selectivly
    spools transformed files to a real printer. Likely, just a script
    that 'lpr's the file, but to printer instead of the pseudo-printer
    from step 2.

    How it works
    a) user queues output to pseudo-printer queue
    b) pseudo-printer reads output, process PCL, saves new PCL in file.
    pseudo-printer /does not/ print anything, but just empties the queue
    c) user runs 'selective print' script to choose one of the saved files
    d) 'selective print' script queues file as output to real printer queue
    e) real printer reads output, processes and prints it



    - --

    Lew Pitcher, IT Specialist, Enterprise Data Systems
    Enterprise Technology Solutions, TD Bank Financial Group

    (Opinions expressed here are my own, not my employer's)
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.4 (MingW32)

    iD8DBQFDWSyAagVFX4UWr64RAkRaAKCGK83HM0HNhPFGgkhWiD GjTkle9ACghjn6
    ZyO43xUUdJM43qF2UeseuwM=
    =VxAY
    -----END PGP SIGNATURE-----

  3. Re: redirect print job to file and process - how?

    Lew Pitcher wrote:
    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > Gary wrote:
    >
    >>I want to share a printer queue to receive a PCL job and save the job as
    >>a file. The name of the file containing the job is then passed to a
    >>process that manipulates the PCL, modifying certain pieces. The “new”
    >>print job saved as a file and is optionally later sent to another queue
    >>for printing.
    >>I can do this in Windows fairly easily using a few tools such as RedMon.
    >>It seems that it would be even simpler to do this under Linux, but I am
    >>very new to Linux and I don’t know how, nor where to look for
    >>information as to how.
    >>I can locate the jobs in the queue, so I could presumably write a script
    >>to pick them out and do what I want to them. I am not sure if I can tell
    >>the spooler the job is gone, or whether I need to. I know that if I do
    >>it this way to Windows it will eventually cause problems.

    >
    >
    > There are likely many different ways to do this in Linux.
    >
    > FWIW, I'd tackle it this way:
    >
    > 1) write a script to process the PCL and create a file
    >
    > 2) create a printer queue and printer within the spooler that, instead
    > of printing the data, runs the script on it. This is fairly easy to
    > do in lpr or lprng (I've done it before), but I don't know if CUPS is
    > as easy do set up.
    >
    > 3) set up a process (you define how it is invoked) that selectivly
    > spools transformed files to a real printer. Likely, just a script
    > that 'lpr's the file, but to printer instead of the pseudo-printer
    > from step 2.
    >
    > How it works
    > a) user queues output to pseudo-printer queue
    > b) pseudo-printer reads output, process PCL, saves new PCL in file.
    > pseudo-printer /does not/ print anything, but just empties the queue
    > c) user runs 'selective print' script to choose one of the saved files
    > d) 'selective print' script queues file as output to real printer queue
    > e) real printer reads output, processes and prints it


    That's exactly what I intended to do. What I am hoping for is some hint
    as to how to do it, or where to find documentation as to how.
    >>Specifically, I don't see how to set up a printer queue to output a

    print file to disk and then trigger a script, like RedMon does for Windows.
    I do see that under Redhat, CUPs normally runs GhostScript as a filter
    on a spooled file... This is 90% there, and it seems logical that I
    could substitute my own program (or script) for GhostScript. But how?
    And will this gracefully remove the job from the queue?

    An example that illustrates what I am afraid of: In Windows, if I just
    put a queue on hold and grab the print job out of the queue folder,
    deleting it when I am done, this works perfectly for a long while. But
    the paused Windows queue does not forget the "pending" job even when the
    job is deleted by another process, and it has a hissy fit when the
    spooled job count exceeds four digits. So, after I have processed 9,999
    files, undefined bad stuff happens. It's possible to do it that way only
    if I also implement some mechanism to clear the queue counter as well as
    the actual queue.
    I am afraid that in Linux if I just do something that seems to work, I
    will set a time bomb for myself.

+ Reply to Thread