470,613 Members | 2,348 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,613 developers. It's quick & easy.

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

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
gj******@cox.net
Jul 19 '05 #1
3 7214
Gary Efron <ge*****@cox.net> wrote in message news:<VbO%b.3085$506.900@fed1read05>...
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; }
Jul 19 '05 #2
Roel van der Steen wrote:
Gary Efron <ge*****@cox.net> wrote in message news:<VbO%b.3085$506.900@fed1read05>...
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; }


Thanks for your help, but I was trying to write to a local printer.
Gary Efron
gj******@cox.net
Jul 19 '05 #3
Gary Efron <ge*****@cox.net> wrote in message news:<PMN1c.27985$aZ3.27893@fed1read04>...
Thanks for your help, but I was trying to write to a local printer.


Maybe you just want to try Win32::Printer?
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Arthur | last post: by
54 posts views Thread by Sathyaish | last post: by
3 posts views Thread by Larry Maturo | last post: by
6 posts views Thread by atinti | last post: by
9 posts views Thread by =?Utf-8?B?Sm9obiBBdXN0aW4=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.