Net::Printer opens a socket connection to the print server/printer. Does your webserver allow that??? (EDIT: obviously it does because you got something printed out but perhaps the connection is killed?)

Net::Printer's documentation does not mention the debug option to new(). Add debug => 'Yes' to new Net::Printer() and see if any messages can help you.

I would also move print "Content-Type:text/html\n\n"; before creating the printer object. I was bitten by printing to std* before printing content-type many times. Move it as far up as it can go.

Also, I would convert the cgi script you posted to a normal command-line perl script and use that to test (rather than testing with lp ...).

Replacing Net::Printer with running a system command from a cgi script could become a problem. Because the webserver can be configured not to allow that, at some point in the future. Or to run it on very low priority. Additionally, there are the usual huge security risks that come with allowing a web service taking user input to shell out. The usual response of course being "we are all friends in our intranet". And I stop here.

bw, bliako


In reply to Re: NET::Printer Module not printing to local printer by bliako
in thread NET::Printer Module not printing to local printer by akwe-xavante

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.