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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gary Efron

    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
    gje_news@cox.ne t
  • Roel van der Steen

    #2
    Re: Perl in Windows How Do I Print/Write to the Printer

    Gary Efron <gefron2@cox.ne t> wrote in message news:<VbO%b.308 5$506.900@fed1r ead05>...[color=blue]
    > 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.[/color]
    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::INE T->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; }

    Comment

    • Gary Efron

      #3
      Re: Perl in Windows How Do I Print/Write to the Printer

      Roel van der Steen wrote:
      [color=blue]
      > Gary Efron <gefron2@cox.ne t> wrote in message news:<VbO%b.308 5$506.900@fed1r ead05>...[color=green]
      > > 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.[/color]
      > 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::INE T->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; }[/color]

      Thanks for your help, but I was trying to write to a local printer.
      Gary Efron
      gje_news@cox.ne t

      Comment

      • Roel van der Steen

        #4
        Re: Perl in Windows How Do I Print/Write to the Printer

        Gary Efron <gefron2@cox.ne t> wrote in message news:<PMN1c.279 85$aZ3.27893@fe d1read04>...[color=blue]
        > Thanks for your help, but I was trying to write to a local printer.[/color]

        Maybe you just want to try Win32::Printer?

        Comment

        Working...