HP3000-L Archives

July 2000, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Lars Appel <[log in to unmask]>
Reply To:
Lars Appel <[log in to unmask]>
Date:
Thu, 6 Jul 2000 14:10:36 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (75 lines)
Me after Lane wrote...

>> So this brings up the next logical question... Does anybody have a program
>> to convert spoolfiles to straight text files that would work with txt2pdf?

>Well, I have a small Java program that listens to a given port,
>for example 9100, and "pretends to be a network printer" i.e. gets
>all the data sent and writes it to a flat file. This might be a
>start, as OUTSPTJ.PUB.SYS should have converted CCTL to plain PCL
>when sending to a JetDirect printer.
>
>However, this little Java program is just a quick & dirty experiment.

Ooops. I meant to send this to Lane, not to the list. However, now
that I have been bragging about this little piece of Java code (and
increased the risk of another "language wars" thread ;-) , I might
as well go ahead and share it here -- especially since it is much
shorter then human Genome maps or similar ;-)

Use at your own risk; it worked on my 3000, but your milage may vary.

Lars.

PS... Anybody willing to code the same in C using Berkeley Sockets?
      I did this once with a small example and began to *love* Java.


_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ cut here _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

// FakeLP pretends network printer to capture spooler PCL output

import java.net.*;
import java.io.*;

class FakeLP {

  public static void main( String args[] ) throws Exception {

    int port = 9100;
    int next = 1;

    if (args.length > 0) port = Integer.parseInt(args[0]);
    if (args.length > 1) next = Integer.parseInt(args[1]);

    ServerSocket serv = new ServerSocket( port );

    while (true) {

      System.out.println("FakeLP listener ready");

      Socket sock = serv.accept();
      byte[] buf = new byte[4096];
      String name = "F" + (next++);

      System.out.println("Capturing spoolfile to " + name);

      InputStream si = sock.getInputStream();
      OutputStream fo = new FileOutputStream(name);

      for (;;)
      {
        int got = si.read(buf);

        if (got != -1)
          fo.write(buf, 0, got);
        else
          break;
      }

      fo.close();
      si.close();
    }
  }
}

ATOM RSS1 RSS2