Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We have a propriety system that talks to various printers across multiple sites via TCP/IP. The system only outputs Postscript, which obviously sends via TCP/IP. I'm really wondering is there any kind of software that I could install my PC which I could setup as like a dummy printer to capture this postscript data.

This would enable me to perform various testing to ensure reports are coming out intact. We have no access to the underlying system or database so this postscript has to be captured as it is output.

I don't need to convert it to PDF or any other format, but that would be nice.

share|improve this question

7 Answers 7

You don't say what operating system this is, but you could use something like TCPflow, wireshark or tcpdump to capture the packets as it is sent across the network.

If this is Windows, I believe, back in the day, that most printer dialogs let you print to a file. This would presumably be the output of the relevant driver. It's been so long since I used Windows that you can probably safely ignore this paragraph. It's possibly a Windows 3.11 thing.

share|improve this answer
up vote 2 down vote accepted

This is how I solved this problem:

I setup RawPrinterServer which will listen as a service on port 9100. I then installed RedMon and Ghostscript.

Redmon allows me to create a custom printer port in windows that will forward print jobs to any software you like.

Ghostscript will interpret the incoming postscript and output it as a PDF.

I created a printer in windows with a custom redirected port that directs to the ghostscript executable.

Program path: C:\BIN\gs\gs8.63\bin\gswin32c.exe

Parameters: -sDEVICE=pdfwrite -dPDFX=true -dNOPAUSE -dSAFER -sPAPERSIZE=a4 -sOutputFile="C:\bin\output.pdf" -c .setpdfwrite -f -

Now in the proprietry software that I use, I setup a printer, directing it to the IP of my computer with port 9100.

Now when I print to my new 'printer' the software sends the postscript to my IP, RawPrintServer accepts the TCP data and forwards it to the printer I setup, the custom printer port forwards that data onto Ghostscript, which saves PDF file on my local machine.

share|improve this answer

I would vote for Wireshark, as it is able to easily follow the TCP strem for the LPD protocol and save it to a file.

I just tested that, and all you have to to is stripping a few lines from the beginning of the output file and you have valid PS.

share|improve this answer

I would have netcat listen on your local LPD port and write what it receives to a file. For example:

nc -l -p 515 > output.ps
share|improve this answer
1  
Note that you don't get a valid postscript from that, as there a few lines of lpd headers before the postscript starts. But it's easy to remove them. –  Sven Jun 15 '09 at 15:52
    
That sounds great. Note that you can also get ncat, which is purportedly netcat on steroids and part of the nmap project. nmap-ncat.sourceforge.net –  Clinton Blackmore Nov 3 '09 at 23:13

Is the proprietory system printing using LPR? If so you could, in principle at least, run an LPR server that wrote the postscript it receives to a file instead of to a printer. I don't know of one offhand, though a quick Google revealed quite a lot of Windows LPR related stuff.

If you're handy with a C++ compiler I have the code for an LPR server lying around somewhere. I wrote this back in the NT3.50 days before Windows supported LPR natively. It wouldn't be hard to modify the code to send the output to a file instead of a printer port. This has to be a last resort though, there must be something out there that does the job.

One thought. Suppose you install the Windows unix printing support on your workstation or some convenient server then put the printer offline and print to it. The postscript would presumably appear in the C:\Windows\system32\spool\PRINTERS somewhere.

JR

share|improve this answer

On Linux you could use tcpdump or wireshark, on Windows I only know of wireshark, personally I like wireshark better because it has a nice GUI, however you can record tcpdump to a file and feed that to wireshark for later analysis

share|improve this answer
  1. Setup a postscript printer which is on 127.0.0.1.

    Adding a post script printer on OSX

  2. Start a netcat server process to fake the printer. HP Jetdirect uses port 9100 nc -l 127.0.0.1 9100 > printout.ps

  3. Print your document and enjoy the postscript grooviness :)

PS: I did this to get around content viewing restrictions on PDFs.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.