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

Discussion in 'Perl' started by Gary Efron, Feb 27, 2004.

  1. Gary Efron

    Gary Efron Guest

    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
     
    Gary Efron, Feb 27, 2004
    #1
    1. Advertising

  2. Gary Efron <> 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; }
     
    Roel van der Steen, Mar 4, 2004
    #2
    1. Advertising

  3. Gary Efron

    Gary Efron Guest

    Roel van der Steen wrote:

    > Gary Efron <> 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
     
    Gary Efron, Mar 4, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Samuel Lee
    Replies:
    0
    Views:
    523
    Samuel Lee
    Nov 11, 2003
  2. Samantha

    Print to Windows default Printer

    Samantha, Jan 18, 2005, in forum: Python
    Replies:
    2
    Views:
    321
    Samantha
    Jan 18, 2005
  3. Tim Golden

    RE: Print to Windows default Printer

    Tim Golden, Jan 19, 2005, in forum: Python
    Replies:
    3
    Views:
    355
    Samantha
    Jan 20, 2005
  4. Tim Golden

    RE: Print to Windows default Printer

    Tim Golden, Jan 20, 2005, in forum: Python
    Replies:
    1
    Views:
    356
    Samantha
    Jan 20, 2005
  5. Replies:
    5
    Views:
    149
Loading...

Share This Page