kleinbiker7 has asked for the wisdom of the Perl Monks concerning the following question:

Sirs, We are trying to print some information to the printer.

Unfortunately, our network is not set up, so that you can do a simple call like:

system ("cat filename.txt < lptr"); # or something like that.

Is there any other way to communicate between the script and the printer, or do I need to install Net::Printer?

Also, I read in the Net::Printer documentation that the printer must speak BSD, not SMB or SysV. I am not familiar with this terminology.

Anyway, the printer in question is a Hewlett Packard Laserjet 5si.

Thanks!

Kleinbiker7

Replies are listed 'Best First'.
Re: How to send output from a Perl script to the printer
by arturo (Vicar) on Mar 06, 2001 at 05:57 UTC

    I think more details are going to be needed to answer this question. Chief among them are:

    • is the printer standalone, or attached to a printer server?
    • What OS is the printer server running? (if the printer's not standalone)
    • What system is the printer using (if it is standalone)
    • What OS are you running the Perl script on?

    The UNIX world is used to the BSD printing system; Net::Printer is capable of speaking to that system only (as things currently stand). Odds are better than even that if your printer is attached to a *nix system (e.g. Linux, *BSD, Solaris) that system is running a version of BSD lpr (or at least something that can grok it). My experience with recentish HP standalone networked printers is that their builtin printer server software groks BSD lpr, so you may already be a winner with Net::Printer in these cases.

    SMB is the protocol by which a Windows system shares its printer, so if your printer is attached to a Windows system, you'll have to go through SMB at some point. You can ease the pain pretty quickly, though, if you're running a *nix flavor: with Samba (distributed with most *nices today), you mount the remote printer as if it were any other networked printer; all you do once the system's set up is pump your script's output to the right printer with

    cat filename | lpr -P[printername]

    Finally, if you're on Windows and the printer is also attached to a windows system ... well, here I'm not so sure, 'cos I don't use Perl on Win32 ... I looked through the available modules, but none seemed particularly well suited to the task. You might look into using Win32::OLE, but that seems (a) indirect and (b) like swatting a fly with a sledgehammer.

    HTH

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor