<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Perl Network Printing Script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054030#M48728</link>
    <description>Ralph,&lt;BR /&gt;&lt;BR /&gt;     I appreciate your feedback/pointers.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thread Close.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;JC.</description>
    <pubDate>Fri, 22 Jun 2007 06:48:45 GMT</pubDate>
    <dc:creator>Junior C.</dc:creator>
    <dc:date>2007-06-22T06:48:45Z</dc:date>
    <item>
      <title>Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054018#M48716</link>
      <description>I need some help in writing a perl script to print to a network printer from windowsXP. &lt;BR /&gt;&lt;BR /&gt;Searching Google I found info indicating that I have to open a socket to the destination IP address and port and dump the data which will&lt;BR /&gt;transparently be sent to the printer. What module do I used to open the socket?&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;my $port='xxxx';&lt;BR /&gt;my $default_printer='xx.xx.xx.xx';&lt;BR /&gt; &lt;BR /&gt;open(OUTPUT_PRINTER,"&amp;gt; \\\\$default_printer\\$port") || die "Unable to&lt;BR /&gt;open printer: $!\n"; print OUTPUT_PRINTER "This is a test Line\n";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Appreciate all help.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;JC&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Jun 2007 12:43:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054018#M48716</guid>
      <dc:creator>Junior C.</dc:creator>
      <dc:date>2007-06-20T12:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054019#M48717</link>
      <description>try Net::LPR</description>
      <pubDate>Wed, 20 Jun 2007 12:50:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054019#M48717</guid>
      <dc:creator>Court Campbell</dc:creator>
      <dc:date>2007-06-20T12:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054020#M48718</link>
      <description>I guess a link may help:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://search.cpan.org/~dmlloyd/Net-LPR-1.007/LPR.pod" target="_blank"&gt;http://search.cpan.org/~dmlloyd/Net-LPR-1.007/LPR.pod&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Jun 2007 12:51:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054020#M48718</guid>
      <dc:creator>Court Campbell</dc:creator>
      <dc:date>2007-06-20T12:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054021#M48719</link>
      <description>Net::printer also looks promising.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://search.cpan.org/~cfuhrman/Net-Printer-1.04/lib/Net/Printer.pm" target="_blank"&gt;http://search.cpan.org/~cfuhrman/Net-Printer-1.04/lib/Net/Printer.pm&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Jun 2007 13:01:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054021#M48719</guid>
      <dc:creator>Court Campbell</dc:creator>
      <dc:date>2007-06-20T13:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054022#M48720</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Network printers use a variety of port numbers.&lt;BR /&gt;&lt;BR /&gt;Common ones are 9100 for JetDirects, and 515 for LPD based printers.&lt;BR /&gt;&lt;BR /&gt;What printer are you using specifically ?&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Rob</description>
      <pubDate>Thu, 21 Jun 2007 01:42:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054022#M48720</guid>
      <dc:creator>Rob Leadbeater</dc:creator>
      <dc:date>2007-06-21T01:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054023#M48721</link>
      <description>The following will work:&lt;BR /&gt;use IO::Socket;&lt;BR /&gt;my $remote_host = 'x.x.x.x';&lt;BR /&gt;my $remote_port = 'x';&lt;BR /&gt;my $socket = IO::Socket::INET-&amp;gt;new(PeerAddr =&amp;gt; $remote_host,PeerPort =&amp;gt; $remote_port,Proto =&amp;gt; 'tcp',Type =&amp;gt; SOCK_STREAM) || die "Couldn't connect to $remote_host\:$remote_port : $!\n";&lt;BR /&gt;print $socket "This is a test line - hello world\n";&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Jun 2007 02:04:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054023#M48721</guid>
      <dc:creator>Alexander Chuzhoy</dc:creator>
      <dc:date>2007-06-21T02:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054024#M48722</link>
      <description>Rob,&lt;BR /&gt;&lt;BR /&gt;What printer are you using specifically ?&lt;BR /&gt;  515 for LPD based printers.&lt;BR /&gt;&lt;BR /&gt;I want to print doc to printer MYPRINTER port 515.&lt;BR /&gt;&lt;BR /&gt;Appreciate your help&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;JC.</description>
      <pubDate>Thu, 21 Jun 2007 07:11:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054024#M48722</guid>
      <dc:creator>Junior C.</dc:creator>
      <dc:date>2007-06-21T07:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054025#M48723</link>
      <description>There are also printers that support both jetdirect and lpd.</description>
      <pubDate>Thu, 21 Jun 2007 07:50:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054025#M48723</guid>
      <dc:creator>Court Campbell</dc:creator>
      <dc:date>2007-06-21T07:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054026#M48724</link>
      <description>Are you wanting suggestions or are you wanting some one to write the script for you?</description>
      <pubDate>Thu, 21 Jun 2007 08:25:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054026#M48724</guid>
      <dc:creator>Court Campbell</dc:creator>
      <dc:date>2007-06-21T08:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054027#M48725</link>
      <description>Court,&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;   Are you wanting suggestions or are you &amp;gt;&amp;gt;wanting some one to write the script for you?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I do not someone to write the script for me.  That will defeat the whole purpose of me learning(well trying)to learn perl.   &lt;BR /&gt;&lt;BR /&gt;Suggestion, example, will be appreciated.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;JC. &lt;BR /&gt;</description>
      <pubDate>Thu, 21 Jun 2007 08:47:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054027#M48725</guid>
      <dc:creator>Junior C.</dc:creator>
      <dc:date>2007-06-21T08:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054028#M48726</link>
      <description>All,&lt;BR /&gt;&lt;BR /&gt;  I did make some progress, well I can print doc to my network printer.&lt;BR /&gt;&lt;BR /&gt;Following are my script.   &lt;BR /&gt;&lt;BR /&gt;I'm not sure how to print heading.&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use vars '@ARGV';&lt;BR /&gt;use Net::LPR;&lt;BR /&gt;use IO::File;&lt;BR /&gt;&lt;BR /&gt;#if (scalar(@ARGV) &amp;lt; 2){die "\\nUsage: $0 &lt;FILENAME&gt; &lt;PRINTER&gt; &lt;QUEUE&gt;\n";};&lt;BR /&gt;&lt;BR /&gt;my $var0 = "myfile.txt";&lt;BR /&gt;my $var1 = 'printer';&lt;BR /&gt;&lt;BR /&gt;my $lp = new Net::LPR(&lt;BR /&gt;         StrictRFCPorts =&amp;gt; 0,&lt;BR /&gt;         RemoteServer   =&amp;gt; $var1,&lt;BR /&gt;         RemotePort     =&amp;gt; 515,&lt;BR /&gt;         PrintErrors    =&amp;gt; 0,&lt;BR /&gt;         RaiseErrors    =&amp;gt; 0,&lt;BR /&gt;                     ) || die "Can't create print context\n";&lt;BR /&gt;                     &lt;BR /&gt;my $fh = new IO::File $var0, O_RDONLY or die "Can't open $var0: $!\n";&lt;BR /&gt;#my $fh = new IO::File $ARGV[0], O_RDONLY or die "Can't $ARGV[0] $!\n";&lt;BR /&gt;&lt;BR /&gt;my $size = ($fh-&amp;gt;stat())[7];&lt;BR /&gt;&lt;BR /&gt;$lp-&amp;gt;connect() || die "Can't connect to printer $var1: ".$lp-&amp;gt;error."\n";&lt;BR /&gt;&lt;BR /&gt;my $jobkey = $lp-&amp;gt;new_job() || die "Can't create new job: ".$lp-&amp;gt;error."\n";&lt;BR /&gt;&lt;BR /&gt;$lp-&amp;gt;send_jobs('lp') || die "Can't send jobs: ".$lp-&amp;gt;error."\n";&lt;BR /&gt;&lt;BR /&gt;# Can easily print postscript by changing method to job_mode_postscript&lt;BR /&gt;$lp-&amp;gt;job_mode_text($jobkey) || die "Can't set job mode to text: ".$lp-&amp;gt;error."\n";&lt;BR /&gt;&lt;BR /&gt;$lp-&amp;gt;job_send_control_file($jobkey) || die "Can't send control file: ".$lp-&amp;gt;error."\n";&lt;BR /&gt;&lt;BR /&gt;$lp-&amp;gt;job_send_data($jobkey, '', $size);&lt;BR /&gt;&lt;BR /&gt;while (my $line = $fh-&amp;gt;getline())&lt;BR /&gt;{&lt;BR /&gt;   $lp-&amp;gt;job_send_data($jobkey, $line);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;$lp-&amp;gt;disconnect();&lt;BR /&gt;&lt;BR /&gt;__END__&lt;/QUEUE&gt;&lt;/PRINTER&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Thu, 21 Jun 2007 08:55:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054028#M48726</guid>
      <dc:creator>Junior C.</dc:creator>
      <dc:date>2007-06-21T08:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054029#M48727</link>
      <description>As Alexander already has shown you &lt;BR /&gt;the generic (OO interface) for Internet sockets in Perl would be IO::Socket::INET&lt;BR /&gt;(if you are more used to the procedural BSD Socket API you could also use the Perl Socket module, but this requires more function calls and awkward address translations).&lt;BR /&gt;However, this leaves the burden of compliance to the application's protocol to you.&lt;BR /&gt;So, fine that you found a more specialized module like Net::LPR.&lt;BR /&gt;I have to admit that I have never used it,&lt;BR /&gt;but I guess you found your way by its POD.&lt;BR /&gt;Maybe just a few "hints"?&lt;BR /&gt;There is no need to "use vars" on @ARGV&lt;BR /&gt;as this is implicitly a package global.&lt;BR /&gt;Besides, "use vars" is obsolete, and globals should be declared by "our" instead.&lt;BR /&gt;Also there is no need to scalar @ARGV if Perl can find out the ("Do What I Mean") context by itself.&lt;BR /&gt;So "if (@ARGV &amp;lt; 2)" should suffice.&lt;BR /&gt;But it never hurts to be explicit.&lt;BR /&gt;As you aren't using much functionality of IO::File (or those inherited from IO::Handle)&lt;BR /&gt;it seems a bit wasteful.&lt;BR /&gt;For instance to get the size of a file this would suffice: "my $size = -s $fh" (see perldoc -f -s).&lt;BR /&gt;So you don't even need to call stat().&lt;BR /&gt;Instead of instatiating an IO::File object&lt;BR /&gt;you could use a simple open() of the file whose content is to be printed.&lt;BR /&gt;If you passed that (or more) file(s) as arguments along with your Perl script invocation some further magic happens,&lt;BR /&gt;in that the file is implicitly opened and its name temporarily stored in $ARGV.&lt;BR /&gt;Then by assigning the buffer variable in the read loop to "&amp;lt;&amp;gt;" you can even omit the getline() call.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Jun 2007 03:59:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054029#M48727</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2007-06-22T03:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Network Printing Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054030#M48728</link>
      <description>Ralph,&lt;BR /&gt;&lt;BR /&gt;     I appreciate your feedback/pointers.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thread Close.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;JC.</description>
      <pubDate>Fri, 22 Jun 2007 06:48:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-network-printing-script/m-p/5054030#M48728</guid>
      <dc:creator>Junior C.</dc:creator>
      <dc:date>2007-06-22T06:48:45Z</dc:date>
    </item>
  </channel>
</rss>

