chumley has asked for the wisdom of the Perl Monks concerning the following question:
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Redirecting print output from WinNT to Unix
by kschwab (Vicar) on Mar 25, 2001 at 06:33 UTC | |
Re: Redirecting print output from WinNT to Unix
by a (Friar) on Mar 25, 2001 at 10:48 UTC | |
Re: Redirecting print output from WinNT to Unix
by t0mas (Priest) on Mar 26, 2001 at 01:20 UTC | |
by chumley (Sexton) on Mar 26, 2001 at 09:41 UTC |