I need to redirect print output from an NT box to a Perl script running on Unix, where the text will be parsed and inserted into a database. Up to now I have been using a Lantronix device that outputs text over a TCP/IP connection. However, it's unreliable, and I'd like to set up a software-only connection.

I created a listener on the Unix server, that looks like this:

use IO::Socket; $sock = new IO::Socket::INET (LocalHost => 'UNIXhost', LocalPort => 3001, Proto => 'tcp', Listen => 5, Reuse => 1 ); die "Socket could not be created. Reason: $!\n" unless $sock; while ($new_sock = $sock->accept()) { while (defined ($buf = <$new_sock>)) { chomp ($buf); print "$buf\n"; } print "EOM\n\n"; } close ($sock);

(This is based on an example in "Advanced Perl Programming")

This works if I telnet to UNIXhost on port 3001 and type in some text.

I created a printer on the NT machine that uses a redirection to port 3001 on UNIXhost. The printer uses the Generic / Text Only driver supplied with Windows. When I submit a print job, the listener running on the Unix box prints "LPT1" and stops, and the print job hangs in NT. If I cancel the print job and submit a new one I see "LPT1" again on UNIXhost.

Is there something I should do to allow the socket to read the entire message? Is there a module that will allow a socket to emulate a print device? I looked through CPAN and the ActiveState docs and didn't find much help.

Thanks in advance,

Chumley


In reply to Redirecting print output from WinNT to Unix by chumley

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.