Jump to content
Sign in to follow this  
mattkmiller

I need a hero

Recommended Posts

mattkmiller

I have been on hiatus from scripting for 2 years. I have recently been contracted by my former employer to help out with a couple of time sensitive projects. I am trying to write a script that needs a piece I have never dealt with before. Do to the time crunch; Im looking for some help.

I need to tell an AS400 to send a print job to a computer. The AS400 needs to think that it is sending to a printer. I need the PC to have a script running that listens for incoming print jobs and then executes other processes on the incoming file. I cant get my mind around the listening piece.

I am looking for a script that will listen for incoming print jobs and then do something with the incoming file. The something is in the rests of my script.

Share this post


Link to post
Share on other sites
boji

Have your comp "listen" to the spool?

If I understand you correctly, there has to be someting in there that pops when your comp gets (makes?) a request to print.

Share this post


Link to post
Share on other sites
Jos

Assuming you use the IP defined printer which uses the LPR protocol, you will need to listen to port 515 after which you need to capture the 2 files send to you. One file ontains the Job information and the orther contains the actual printer data.

I once wrote a VB which functions as an LPD and would forward the generated output to the EMail address connected to the target printername.

It was able to handle 10 concurrent print jobs.

This is not a trivial task to write a dedicated script. Attached is the RFC that describes the whole process of an LPD.

One other approach could be to have a dedicated PC and install the Microsoft Printing for Unix on it, which is the LPD. Then define a printer which will print to a file. everytime you print to it you will be prompted for the target file. so make a script to wait for that outputfile prompt, fill it in and wait for the print to finish. After that you can process the file.

Just thinking out loud here :)

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Juvigy

Why not set up a virtual printer that prints to a file or to a PDF and saves it in your local hard drive. Then you can do whatever you like on the file.

Share this post


Link to post
Share on other sites
mattkmiller

Thank you for your response. One issue I have is that I cannot touch the AS400 other than to tell ot what IP the "printer" is at. So there's no installing, setup, or file location instruction options on the source machine.

Setting this up via standard network printer setup would require me to be able to tell the source machine the name of the printer attached to the destination PC. But again, I cannot tell the AS400 anything other than the printer IP. The destination PC will be a designated PC for this process. No printer will actually be attached.

Thinking out loud is how we get things done.

Share this post


Link to post
Share on other sites
Jos

Thank you for your response. One issue I have is that I cannot touch the AS400 other than to tell ot what IP the "printer" is at. So there's no installing, setup, or file location instruction options on the source machine.

Setting this up via standard network printer setup would require me to be able to tell the source machine the name of the printer attached to the destination PC. But again, I cannot tell the AS400 anything other than the printer IP. The destination PC will be a designated PC for this process. No printer will actually be attached.

Thinking out loud is how we get things done.

When the AS400 prints to an LPD it will use a remote printername so its a matter of figuring out what that is and create a printer with that name.

Did you try setting up theUnix printing on a PC and give that a try to see what happens?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
CesareGenova

Last year I had to process the PCL output from an AIX host; my only chance was to configure a PC as a virtual printer and assign a proper IP address to it. I used a little LPD daemon written a few years ago by Rocco LaPadula, a smart (and kind) guy from Canada. The daemon keep listening to port 515 and creates a couple of files for each print job received. I added a small AutoIt script to monitor the directory and process the data. It still runs pretty well. The solution has a couple of limits you have to work around. The directory where received jobs are enqued is the same from where you launch the exe; file names assigned to received jobs are serialized using an internal counter which is limited to 100, so you have to include some kind of housecleaning in your code.

Here you can find a link to the binary lpd.exe

http://www.digitalissues.co.uk/html/software/utils/pdl-capture.html

I really hope you can find my solution useful for addressing your problem.

Cesare

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×