Perl in Windows How Do I Print/Write to the Printer

G

Gary Efron

Hi,
I can write and print to the terminal, but do not know how to write or
print to the printer. The examples I saw, did not work. Please either
tell me or direct me to some documentation.
Thanks, in advance,
Gary
(e-mail address removed)
 
R

Roel van der Steen

Gary Efron said:
I can write and print to the terminal, but do not know how to write or
print to the printer. The examples I saw, did not work. Please either
tell me or direct me to some documentation.
Open a filehandle and write to that handle. If your printer is on the
network, do something like:

use IO::Socket;
my $remote_host = '192.168.1.49';
my $remote_port = '9100';
my $socket = IO::Socket::INET->new(
PeerAddr => $remote_host,
PeerPort => $remote_port,
Proto => 'tcp',
Type => SOCK_STREAM,
) || die "Couldn't connect to $remote_host\:$remote_port : $@\n";
while ( my $psdata = <DATA> ) { print $socket $psdata; }
 
G

Gary Efron

Roel said:
Open a filehandle and write to that handle. If your printer is on the
network, do something like:

use IO::Socket;
my $remote_host = '192.168.1.49';
my $remote_port = '9100';
my $socket = IO::Socket::INET->new(
PeerAddr => $remote_host,
PeerPort => $remote_port,
Proto => 'tcp',
Type => SOCK_STREAM,
) || die "Couldn't connect to $remote_host\:$remote_port : $@\n";
while ( my $psdata = <DATA> ) { print $socket $psdata; }

Thanks for your help, but I was trying to write to a local printer.
Gary Efron
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top