[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

lp and lpr "stdin is empty"

I just upgraded to Fedora core 2 from core 1, and now lp and lpr
cannot read from standard input.

[allan mybox bin]$ /usr/bin/lp < /etc/hosts
lp: stdin is empty, so no job has been sent.
[allan mybox bin]$ /usr/bin/lp /etc/hosts
request id is laserjet-977 (1 file(s))

Printing a file works, but as you see printing from a pipe was busted,
and so any programs that relied on pipes were SOL.  I did notice a
nonexistent printer in the /etc/cups/lpoptions file, and I fixed that.

Strange though that only printing a file works.

I wrote a workaround perl script, and noticing that /usr/local/bin was
in the path before /usr/bin, I put it there as a wrapper for the real
lp and lpr programs.  At least I can print now. Any thoughts?

Here is my workaround, I named it lp, and symlinked it to lpr:

# -*- cperl -*-

# quick wrapper around lp for stdin bug
# pedaa_at_rockefeller.edu
# Time-stamp: <2004-10-29 12:15:44 allan>
use strict;
use Carp;
use File::Temp qw( tempfile );
use File::Basename qw(basename );
my $LPEXE = "/usr/bin/".basename( $0 );

# if given stdin, buffer to file, else call prog directly
unless( defined($ARGV[$#ARGV]) and (-f $ARGV[$#ARGV]) ){
    my $fbuff = new File::Temp( TEMPLATE => 'lpXXXXX',
				DIR => '/tmp',
				SUFFIX => '.cups' );

    print $fbuff <STDIN>;
    system( $LPEXE, @ARGV, $fbuff );
} else {
    exec( $LPEXE, @ARGV );

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]